Conversation
We shouldn't need to fetch _every_ unrelated branch from the repo to backport changes between two branches - this may be non-trivial for big repos. [Example execution](https://github.com/JackPGreen/backport-test/actions/runs/20109278003) & [resultant PR](JackPGreen/backport-test#252).
| log_info "Pushing $BRANCH_NAME to origin" | ||
| # https://github.com/cli/cli/issues/1718#issuecomment-748292216 | ||
| git pull | ||
| git push -u origin HEAD |
There was a problem hiding this comment.
Why did we have this git pull?
There was a problem hiding this comment.
It was added in #6, but shouldn't have been.
Specifically - the backport action a makes a new branch (e.g. backport-pr-5543-5.6.z) - there should be no need to pull a branch we just made.
However, the branch name isn't very unique - if you run the action again by clicking Rerun in the GitHub UI it will use the same branch name as last time and then complain there's a branch on the remote with the same name as your local one - but they aren't the same branch because you didn't pull it.
During development I didn't realise this and thought we always had to pull - but actually it's only needed if you re-run, which is really only a development task.
The generated branch names probably should be more unique but it's not really a problem.
| # Add explicit "upstream" remote as required by backport script | ||
| git remote add upstream "${{ github.event.repository.clone_url }}" | ||
| git fetch --all | ||
| git fetch upstream --unshallow "${{ matrix.branch }}" |
There was a problem hiding this comment.
Why
--unshallow?
You get a conflict during cherry-pick:
error: could not apply 531d15a... Create 173 (#265)
|
does this improve efficiency? |
Difficult to benchmark in a real repo with a large history without merging arbitrary PRs, but... Previously took 104 seconds in the |
|
I'm not convinced the problem this PR is trying to address is solvable - Git requires commit history to effectively compute a diff for We do a shallow checkout and then a bunch of |
We shouldn't need to fetch every unrelated branch from the repo to backport changes between two branches - this may be non-trivial for big repos.
Example execution & resultant PR.