Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/component_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,12 @@ def __create_branch_and_pr(self, repo_dir, original_component: AtmosComponent, u
logging.info(f"Created branch: {branch_name} in 'origin'")
logging.info(f"Opening PR for branch {branch_name}")

current_ref = original_component.version or ''
git_log_summary = self.__tools_manager.git_log_between_versions(repo_dir, current_ref, latest_tag)
pull_request_creation_response: PullRequestCreationResponse = self.__github_provider.open_pr(branch_name,
original_component,
updated_component)
updated_component,
git_log_summary)
if not self.__config.dry_run and pull_request_creation_response.pull_request:
pull_request = pull_request_creation_response.pull_request

Expand Down
6 changes: 4 additions & 2 deletions src/github_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def branch_exists(self, branch_name: str):
def open_pr(self,
branch_name: str,
original_component: AtmosComponent,
updated_component: AtmosComponent) -> PullRequestCreationResponse:
updated_component: AtmosComponent,
git_log_summary: str) -> PullRequestCreationResponse:
original_component_version_link = self.__build_component_version_link(original_component)
updated_component_version_link = self.__build_component_version_link(updated_component)

Expand All @@ -124,7 +125,8 @@ def open_pr(self,
old_version_link=original_component_version_link,
new_version_link=updated_component_version_link,
old_component_release_link=original_component_release_link,
new_component_release_link=updated_component_release_link)
new_component_release_link=updated_component_release_link,
git_log_summary=git_log_summary)

response = PullRequestCreationResponse(branch_name, title, body, self.__config.pr_labels)

Expand Down
6 changes: 6 additions & 0 deletions src/templates/pr_body.j2.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ This is an auto-generated PR that updates component `{{ component_name }}` to ve
| **Old Version** | {% if old_version_link is defined %}[`{{ old_version }}`]({{ old_version_link }}){% else %}`{{ old_version }}`{% endif %}{% if old_component_release_link is defined %}, [Release notes]({{ old_component_release_link }}){% endif %} |
| **New Version** | {% if new_version_link is defined %}[`{{ new_version }}`]({{ new_version_link }}){% else %}`{{ new_version }}`{% endif %}{% if new_component_release_link is defined %}, [Release notes]({{ new_component_release_link }}){% endif %} |

### Git Logs

```
{{ git_log_summary }}
```

## why

[Cloud Posse](https://cloudposse.com) recommends upgrading Terraform components regularly to maintain a secure, efficient, and well-supported infrastructure. In doing so, you'll benefit from the latest features, improved compatibility, easier upgrades, and ongoing support while mitigating potential risks and meeting compliance requirements.
Expand Down
16 changes: 16 additions & 0 deletions src/tools_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,21 @@ def git_get_latest_tag(self, git_dir: str):

return tag.strip().decode("utf-8") if tag else None

def git_log_between_versions(self, git_dir:str, component_path: str, previous_ref: str, future_ref: str = 'main'):
command = ["git", "log", f"{previous_ref}..{future_ref}", component_path]

logging.debug(f"Executing: '{' '.join(command)}' ... ")

response = subprocess.run(command, capture_output=True, cwd=git_dir, check=False)

if response.returncode != 0:
error_message = response.stderr.decode("utf-8")
logging.error(error_message)
return None

log = response.stdout

return log.strip().decode("utf-8") if log else None

def is_git_repo(self, repo_dir: str) -> bool:
return os.path.exists(os.path.join(repo_dir, '.git'))