From 807f3a8fc63877727996ccfd594d5b0b6301de92 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Tue, 4 Oct 2022 08:07:25 -0700 Subject: [PATCH] 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. --- scripts/stubsabot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/stubsabot.py b/scripts/stubsabot.py index 49042c0b0..128c8d21e 100644 --- a/scripts/stubsabot.py +++ b/scripts/stubsabot.py @@ -377,19 +377,19 @@ async def create_or_update_pull_request(*, title: str, body: str, branch_name: s response.raise_for_status() -def origin_branch_has_changes(branch: str) -> bool: +def has_non_stubsabot_commits(branch: str) -> bool: assert not branch.startswith("origin/") try: # number of commits on origin/branch that are not on branch or are # patch equivalent to a commit on branch output = subprocess.check_output( - ["git", "rev-list", "--right-only", "--cherry-pick", "--count", f"{branch}...origin/{branch}"], + ["git", "log", "--right-only", "--pretty=%an", "--cherry-pick", f"{branch}...origin/{branch}"], stderr=subprocess.DEVNULL, ) + return bool(set(output.splitlines()) - {b"stubsabot"}) except subprocess.CalledProcessError: # origin/branch does not exist return False - return int(output) > 0 class RemoteConflict(Exception): @@ -397,7 +397,7 @@ class RemoteConflict(Exception): def somewhat_safe_force_push(branch: str) -> None: - if origin_branch_has_changes(branch): + if has_non_stubsabot_commits(branch): raise RemoteConflict(f"origin/{branch} has changes not on {branch}!") subprocess.check_call(["git", "push", "origin", branch, "--force"])