Describe your question in as much detail as possible:
When a merge request is created, I’d like for my pipeline script to test if the branch that is going to be merged is behind the branch being merged to and if it is, fail the test to help people to remember to rebase. I am running on gitlab.com inside a docker image of my own with git and rockylinux:8 in a private project.
What are you seeing, and how does that differ from what you expect to see?
It seems like inside the docker image, I am just fetching the one last commit, but I’d like to compare the branches. So, if I’m merging develop into main, I want to make sure develop isn’t behind the main branch.
This command in my terminal returns me the commits behind:
git rev-list --left-only --count origin/main..@
but gives me an error on gitlab
ambiguous argument 'main': unknown revision or path not in the working tree
What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
I’ve tried changing the GIT_STRATEGY: to clone and also just manually running git fetch but there still seems to be no information pertaining to the develop or main branches available.
I apologize in advance if I am doing something completely wrong or inherently bad, I am pretty new to both git and gitlab. Thank you.
Hello! Thank you for the reply! I just double checked to make sure and yes I’m at the root of my project and git remote -vv and everything seemed correct. It looked like this (I redacted a few items):