|
14 | 14 |
|
15 | 15 | def push_branch(branch_name: str): |
16 | 16 | try: |
17 | | - subprocess.run(["git", "checkout", "-b", branch_name], check=True) |
| 17 | + subprocess.run(["git", "checkout", "-B", branch_name], check=True) |
18 | 18 | subprocess.run(["git", "config", "user.email", "github-actions@users.noreply.github.com"], check=True) |
19 | 19 | subprocess.run(["git", "config", "user.name", "github-actions"], check=True) |
20 | 20 | subprocess.run(["git", "add", "."], check=True) |
21 | 21 | subprocess.run(["git", "commit", "-m", f"Update policy: {branch_name}"], check=True) |
22 | | - subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True) |
| 22 | + |
| 23 | + try: |
| 24 | + subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True) |
| 25 | + except subprocess.CalledProcessError: |
| 26 | + typer.echo("⚠️ Push failed. Trying to pull + re-push...") |
| 27 | + subprocess.run(["git", "pull", "--rebase", "origin", branch_name], check=True) |
| 28 | + subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True) |
| 29 | + |
23 | 30 | typer.echo(f"✅ Pushed branch {branch_name} to origin.") |
24 | 31 | except subprocess.CalledProcessError as e: |
25 | 32 | typer.echo(f"❌ Git command failed: {e}") |
@@ -64,7 +71,7 @@ def drift( |
64 | 71 |
|
65 | 72 | assignees = [a.strip() for a in approvers.split(",") if a.strip()] |
66 | 73 | issue_num, _ = create_approval_issue(repo_full_name, token, policy_name, assignees=assignees) |
67 | | - #typer.echo(f"✅ Created issue #{issue_num} for approval.") |
| 74 | + typer.echo(f"✅ Created issue #{issue_num} in {repo_full_name}: https://github.com/{repo_full_name}/issues/{issue_num}") |
68 | 75 |
|
69 | 76 | choice = wait_for_sync_choice(repo_full_name, issue_num, token) |
70 | 77 | iam = boto3.client("iam") |
@@ -113,7 +120,8 @@ def _update_local_and_create_pr(doc, policy_file, repo_full_name, policy_name, i |
113 | 120 | pr_body = f"This PR updates `{policy_file}` {description}.\n\nLinked to issue #{issue_num}.".strip() |
114 | 121 | pr_num, pr_url = create_github_pr(repo_full_name, branch, pr_title, pr_body, issue_num=issue_num) |
115 | 122 |
|
116 | | - #typer.echo(f"✅ Created PR #{pr_num}: {pr_url}") |
| 123 | + typer.echo(f"✅ Created PR #{pr_num}: {pr_url}") |
| 124 | + typer.echo(f"💬 Commented on and closed issue #{issue_num}") |
117 | 125 |
|
118 | 126 | # Auto-close issue |
119 | 127 | gh = Github(token) |
|
0 commit comments