Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase to latest commit for which Gitlab CI has finished #95

Open
adamjstewart opened this issue Jul 11, 2024 · 3 comments
Open

Rebase to latest commit for which Gitlab CI has finished #95

adamjstewart opened this issue Jul 11, 2024 · 3 comments
Labels
commands @spackbot commands enhancement New feature or request

Comments

@adamjstewart
Copy link
Member

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:

@spackbot rebase pipeline
@spackbot merge pipeline

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.

@adamjstewart adamjstewart added enhancement New feature or request commands @spackbot commands labels Jul 11, 2024
@vsoch
Copy link
Member

vsoch commented Jul 11, 2024

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!

@adamjstewart
Copy link
Member Author

adamjstewart commented Jul 29, 2024

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.

@adamjstewart
Copy link
Member Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commands @spackbot commands enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants