Merge pull request #5 from davidism/update-pr

update existing branch and pr
This commit is contained in:
David Lord 2025-01-14 14:09:34 -08:00 committed by GitHub
commit 3e778fb77e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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)