Skip to content

Push multiple branches in the stack atomically if no commits reordering happened#31

Merged
dimikot merged 1 commit intomainfrom
grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a
Apr 14, 2025
Merged

Push multiple branches in the stack atomically if no commits reordering happened#31
dimikot merged 1 commit intomainfrom
grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a

Conversation

@dimikot
Copy link
Owner

@dimikot dimikot commented Apr 14, 2025

Summary

Git supports "atomic push" of multiple branches. We now use it in git-grok:

It is faster than pushing one by one.
It is possible that it improves CODEOWNERS-based reviewers addition when a large stack is reordered or rebased.

How was this tested?

CI (there was a test that covers the usecase with reordering).

PRs in the Stack

(The stack is managed by git-grok.)

dimikot added a commit that referenced this pull request Apr 14, 2025
@dimikot dimikot force-pushed the grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a branch 2 times, most recently from 1206f17 to 49e000c Compare April 14, 2025 10:23
dimikot added a commit that referenced this pull request Apr 14, 2025
dimikot added a commit that referenced this pull request Apr 14, 2025
@dimikot dimikot force-pushed the grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a branch from 49e000c to db5f608 Compare April 14, 2025 10:24
dimikot added a commit that referenced this pull request Apr 14, 2025
## Summary

Adding an engine which is able to push multiple branches (commits)
atomically. For now, it still does most of the pushes sequentially, but
using the parallel engine (with commits list size 1).

The problem is that multi-branch push can only be used safely when no
commits reordering happened in the stack (otherwise, GitHub may mark
some of intermediate PRs as merged prematurely, and there is no way out
of it). That's why in the current PR, we do not utilize it much yet. It
will be treated in the next PRs.

## How was this tested?

CI.

## PRs in the Stack
- #31
- #30
- ➡ #29

(The stack is managed by
[git-grok](https://github.com/dimikot/git-grok).)
@dimikot dimikot force-pushed the grok/dimikot/improve-closed-prs-reopening-corner-cases-to-main-c887 branch from e7fe862 to 583b632 Compare April 14, 2025 10:26
dimikot added a commit that referenced this pull request Apr 14, 2025
@dimikot dimikot force-pushed the grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a branch from db5f608 to fc58402 Compare April 14, 2025 10:26
dimikot added a commit that referenced this pull request Apr 14, 2025
## Summary

GitHub is "too smart", so sometimes it marks the PRs as merged or as
closed on its own, right after the PR head branch is force-pushed:
1. If the head branch is force-pushed, and GitHub thinks that all the
code is merged to the upstream already, it marks the PR as merged.
2. If the head branch is force-pushed the way the PR has 0 commits in
it, GitHub closes that PR and makes it unopenable.
3. When the PR is closed anyhow, and then the head branch is
force-pushed to some new commit hash, then GitHub refuses to reopen that
PR (see isaacs/github#361 for details).

We used to cover the case (1) (git-grok was just creating a new PR). Now
we cover the case 2 (the same way as case 1) and case 3 (with a hack
explained at isaacs/github#361).

## How was this tested?

```
git grok
```

All those PRs were closed, then randomly reordered, and git-grok rerun:

![CleanShot 2025-04-13 at 23 05
43@2x](https://github.com/user-attachments/assets/c734bb3a-29a7-465f-b882-69b7f22a6151)

## PRs in the Stack
- #31
- ➡ #30

(The stack is managed by
[git-grok](https://github.com/dimikot/git-grok).)
Base automatically changed from grok/dimikot/improve-closed-prs-reopening-corner-cases-to-main-c887 to main April 14, 2025 10:35
@dimikot dimikot force-pushed the grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a branch from fc58402 to 2b5dd24 Compare April 14, 2025 10:35
@dimikot dimikot merged commit d793185 into main Apr 14, 2025
2 checks passed
@dimikot dimikot deleted the grok/dimikot/push-multiple-branches-in-the-stack-atomically-if-no-commits-reordering-happened-to-main-111a branch April 14, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant