Open adamjstewart opened 1 month ago
I would say maybe rename the second command (and then the first to be consistent) to make it clear it's not an instruction to merge into the main branch, something like:
@spackbot update-rebase pipeline
@spackbot update-merge pipeline
Or similar - just to make it clear!
Command to get the most recent commit that has completed CI (courtesy of @kwryankrattiger):
curl -L "https://gitlab.spack.io/api/v4/projects/2/pipelines?ref=develop&per_page=2" | jq -r .[1].sha
Description: "basically, get the last two pipelines run on develop, then get the sha from the older one"
Then you can do:
git rebase --onto <sha256> develop
to actually update your branch.
For anyone who goes as crazy as me waiting for this feature, I created the following git aliases in my .gitconfig
:
[alias]
# Rebase off of the latest commit that has completed GitLab CI (Spack-only)
#
# Examples:
#
# > git lab merge
# > git lab pull upstream develop
# > git lab rebase develop
lab = "!f() { \
commit=$(curl -L \"https://gitlab.spack.io/api/v4/projects/2/pipelines?ref=develop&per_page=2\" 2> /dev/null | jq -r .[1].sha); \
case \"$1\" in \
merge) \
git merge \"$commit\"; \
;; \
pull | pl ) \
git fetch \"$2\" \"$3\"; \
git merge \"$commit\"; \
;; \
rebase | rb) \
git rebase --onto \"$commit\" \"$2\"; \
;; \
*) \
echo \"Invalid choice: $1\"; \
;; \
esac; \
}; f"
GitHub has a button allowing PR authors and maintainers to rebase the PR branch on develop, or to merge develop into the PR branch. However, there is often a long delay between the tip of develop and the most recent commit for which Gitlab CI has passed. PRs cannot start their own CI until their base commit has finished.
Many core maintainers have their own tricks for rebasing their PR branches on the latest commit for which CI has completed (please share these here!). It would be great if spackbot could do this for me. I don't care too much about naming, but for now I'll propose two new commands:
to rebase or merge the PR branch to the latest commit for which Gitlab CI has completed. Another question is whether it should be the latest finished commit or the latest passing commit.