update existing branch and pr

This commit is contained in:
David Lord 2025-01-14 14:05:14 -08:00
parent d7dbd26e42
commit 4dba24283e
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
2 changed files with 21 additions and 11 deletions

View file

@ -2,6 +2,9 @@
Unreleased
- If a PR already exists from a previous failed run, force push to update the
existing branch and PR.
## Version 0.1.1
Released 2025-01-14

View file

@ -66,14 +66,21 @@ class GitHubRepo(GitRepo):
super().submit()
return
self.git_cmd("push", "--set-upstream", "origin", self.script.branch)
self.gh_cmd(
"pr",
"create",
"--base",
self.script.target,
"--title",
self.script.title,
"--body",
self.script.body,
)
result = self.gh_cmd("pr", "view", "--json", "closed", "--jq", ".closed")
has_pr = not result.returncode and result.stdout.strip() == "false"
if not has_pr:
self.git_cmd("push", "--set-upstream", "origin", self.script.branch)
self.gh_cmd(
"pr",
"create",
"--base",
self.script.target,
"--title",
self.script.title,
"--body",
self.script.body,
)
else:
# If open PR already exists from previous run, force push.
self.git_cmd("push", "--force", "origin", self.script.branch)