Skip to content

Commit 807f3a8

Browse files
authored
Update open stubsabot PRs (#8813)
Fixes #8778 Note that not fixing this has some advantages, particularly if stubsabot waits a little while after releases before making PRs (as discussed earlier). Specifically, it gives us more coverage of upstream versions and might provide a natural division of changes, compared to PRs that make updates corresponding to several upstream versions.
1 parent 5da171b commit 807f3a8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/stubsabot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,27 +377,27 @@ async def create_or_update_pull_request(*, title: str, body: str, branch_name: s
377377
response.raise_for_status()
378378

379379

380-
def origin_branch_has_changes(branch: str) -> bool:
380+
def has_non_stubsabot_commits(branch: str) -> bool:
381381
assert not branch.startswith("origin/")
382382
try:
383383
# number of commits on origin/branch that are not on branch or are
384384
# patch equivalent to a commit on branch
385385
output = subprocess.check_output(
386-
["git", "rev-list", "--right-only", "--cherry-pick", "--count", f"{branch}...origin/{branch}"],
386+
["git", "log", "--right-only", "--pretty=%an", "--cherry-pick", f"{branch}...origin/{branch}"],
387387
stderr=subprocess.DEVNULL,
388388
)
389+
return bool(set(output.splitlines()) - {b"stubsabot"})
389390
except subprocess.CalledProcessError:
390391
# origin/branch does not exist
391392
return False
392-
return int(output) > 0
393393

394394

395395
class RemoteConflict(Exception):
396396
pass
397397

398398

399399
def somewhat_safe_force_push(branch: str) -> None:
400-
if origin_branch_has_changes(branch):
400+
if has_non_stubsabot_commits(branch):
401401
raise RemoteConflict(f"origin/{branch} has changes not on {branch}!")
402402
subprocess.check_call(["git", "push", "origin", branch, "--force"])
403403

0 commit comments

Comments
 (0)