Skip to content

Commit e48737c

Browse files
committed
testing new drift version
1 parent f5ab509 commit e48737c

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

devolv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.2.17"
1+
__version__ = "0.2.18"
22

devolv/drift/cli.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@
1414

1515
def push_branch(branch_name: str):
1616
try:
17-
subprocess.run(["git", "checkout", "-b", branch_name], check=True)
17+
subprocess.run(["git", "checkout", "-B", branch_name], check=True)
1818
subprocess.run(["git", "config", "user.email", "github-actions@users.noreply.github.com"], check=True)
1919
subprocess.run(["git", "config", "user.name", "github-actions"], check=True)
2020
subprocess.run(["git", "add", "."], check=True)
2121
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+
2330
typer.echo(f"✅ Pushed branch {branch_name} to origin.")
2431
except subprocess.CalledProcessError as e:
2532
typer.echo(f"❌ Git command failed: {e}")
@@ -64,7 +71,7 @@ def drift(
6471

6572
assignees = [a.strip() for a in approvers.split(",") if a.strip()]
6673
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}")
6875

6976
choice = wait_for_sync_choice(repo_full_name, issue_num, token)
7077
iam = boto3.client("iam")
@@ -113,7 +120,8 @@ def _update_local_and_create_pr(doc, policy_file, repo_full_name, policy_name, i
113120
pr_body = f"This PR updates `{policy_file}` {description}.\n\nLinked to issue #{issue_num}.".strip()
114121
pr_num, pr_url = create_github_pr(repo_full_name, branch, pr_title, pr_body, issue_num=issue_num)
115122

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}")
117125

118126
# Auto-close issue
119127
gh = Github(token)

devolv/drift/github_approvals.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,22 @@ def create_github_pr(repo: str, head_branch: str, title: str, body: str, base: s
6060

6161

6262
def push_branch(branch_name: str):
63-
"""
64-
Create and push a branch with committed changes.
65-
"""
6663
try:
67-
subprocess.run(["git", "checkout", "-b", branch_name], check=True)
64+
subprocess.run(["git", "checkout", "-B", branch_name], check=True)
6865
subprocess.run(["git", "config", "user.email", "github-actions@users.noreply.github.com"], check=True)
6966
subprocess.run(["git", "config", "user.name", "github-actions"], check=True)
7067
subprocess.run(["git", "add", "."], check=True)
71-
subprocess.run(["git", "commit", "-m", f"Update policy from AWS: {branch_name}"], check=True)
72-
subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True)
68+
subprocess.run(["git", "commit", "-m", f"Update policy: {branch_name}"], check=True)
69+
70+
try:
71+
subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True)
72+
except subprocess.CalledProcessError:
73+
typer.echo("⚠️ Push failed. Trying to pull + re-push...")
74+
subprocess.run(["git", "pull", "--rebase", "origin", branch_name], check=True)
75+
subprocess.run(["git", "push", "--set-upstream", "origin", branch_name], check=True)
7376

7477
typer.echo(f"✅ Pushed branch {branch_name} to origin.")
7578
except subprocess.CalledProcessError as e:
7679
typer.echo(f"❌ Git command failed: {e}")
7780
raise typer.Exit(1)
81+

devolv/drift/issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def create_approval_issue(repo_full_name, token, policy_name, assignees=None):
2424
assignees=assignees or []
2525
)
2626

27-
print(f"✅ Created issue #{issue.number} in {repo_full_name}: {issue.html_url}")
27+
#print(f"✅ Created issue #{issue.number} in {repo_full_name}: {issue.html_url}")
2828
return issue.number, issue.html_url
2929

3030

0 commit comments

Comments
 (0)