diff --git a/src/ghstack/submit.py b/src/ghstack/submit.py index e5015eb..24482bb 100644 --- a/src/ghstack/submit.py +++ b/src/ghstack/submit.py @@ -1479,6 +1479,30 @@ def push_updates( push_branches: List[str] = [] force_push_branches: List[str] = [] + for s in reversed(diffs_to_submit): + # It is VERY important that we do base updates BEFORE real + # head updates, otherwise GitHub will spuriously think that + # the user pushed a number of patches as part of the PR, + # when actually they were just from the (new) upstream + # branch + + for diff, b in s.push_branches: + if b == "orig": + q = force_push_branches + elif b == "base": + q = base_push_branches + else: + q = push_branches + q.append(push_spec(diff, branch(s.username, s.ghnum, b))) + # Careful! Don't push master. + # TODO: These pushes need to be atomic (somehow) + if base_push_branches: + self._git_push(base_push_branches) + if push_branches: + self._git_push(push_branches, force=self.force) + if force_push_branches: + self._git_push(force_push_branches, force=True) + for s in reversed(diffs_to_submit): # NB: GraphQL API does not support modifying PRs assert not s.closed @@ -1516,29 +1540,6 @@ def push_updates( body=stack_desc, ) - # It is VERY important that we do base updates BEFORE real - # head updates, otherwise GitHub will spuriously think that - # the user pushed a number of patches as part of the PR, - # when actually they were just from the (new) upstream - # branch - - for diff, b in s.push_branches: - if b == "orig": - q = force_push_branches - elif b == "base": - q = base_push_branches - else: - q = push_branches - q.append(push_spec(diff, branch(s.username, s.ghnum, b))) - # Careful! Don't push master. - # TODO: These pushes need to be atomic (somehow) - if base_push_branches: - self._git_push(base_push_branches) - if push_branches: - self._git_push(push_branches) - if force_push_branches: - self._git_push(force_push_branches, force=True) - # Report what happened def format_url(s: DiffMeta) -> str: return "https://{github_url}/{owner}/{repo}/pull/{number}".format(