On the Gitlab webpage you have the possibility to check how many commits a branch is behind or ahead of the master branch. My question is if it is possible to get information about this with the "gitlab API"? I checked the docs but unfortunately couldn't find anything.
Gitlab Api Commits Behind/Ahead Master
1000 Views Asked by Tessaiga At
2
There are 2 best solutions below
0
Tolis Gerodimos
On
The specific Gitlab API that does the trick is
GET /projects/:id/repository/compare
More info at https://docs.gitlab.com/ee/api/repositories.html#compare-branches-tags-or-commits
Execution example to bring you number of commits that differentiates the 2 branches
curl -s --header "PRIVATE-TOKEN: <access_token>" "https://gitlab.com/api/v4/projects/<project_id>/repository/compare?from=<branch_name_behind_in_commits>&to=<branch_name_ahead_in_commits>&straight=true" | jq '. | .commits | length'
- If you want to see how many commits is
masterbranchbehindoffeaturebranch. You should add the master tofromfield and feature branch attofield - If you want to see how many commits is
masterbranchaheadoffeaturebranch. You should add the feature branch tofromfield and master branch attofield
Related Questions in PYTHON
- How to store a date/time in sqlite (or something similar to a date)
- Instagrapi recently showing HTTPError and UnknownError
- How to Retrieve Data from an MySQL Database and Display it in a GUI?
- How to create a regular expression to partition a string that terminates in either ": 45" or ",", without the ": "
- Python Geopandas unable to convert latitude longitude to points
- Influence of Unused FFN on Model Accuracy in PyTorch
- Seeking Python Libraries for Removing Extraneous Characters and Spaces in Text
- Writes to child subprocess.Popen.stdin don't work from within process group?
- Conda has two different python binarys (python and python3) with the same version for a single environment. Why?
- Problem with add new attribute in table with BOTO3 on python
- Can't install packages in python conda environment
- Setting diagonal of a matrix to zero
- List of numbers converted to list of strings to iterate over it. But receiving TypeError messages
- Basic Python Question: Shortening If Statements
- Python and regex, can't understand why some words are left out of the match
Related Questions in API
- Google Sheets API - Append Request not working
- Is there really no product for docs that has these?
- How to show suggested content in response using Azure Cognitive Search?
- error message when closing current position in binance futures, using ccxt library
- How to filter API data in React Native
- I have fetched an API with JS, but the output looks really bad and I don't know how to fix it
- Session is not storing in react and Asp Dot Core Web API
- Apex charts not rendering series value, showing cannot map values of NULL
- Configure IIS to accept API calls only from API Manager, Deny from direct calls
- Problems with API return using the Axios library in NextJS
- How to query by Iteration in pyral?
- Is there a way to have a user enter a url query and have a single function filter a database?
- Cant get value in Vue from data
- Read stories/posts using instagram API
- Need To Make Minor Change To REST API Response
Related Questions in GITLAB
- There are no active runners online GitLab
- Error rising in gitlab configuration file
- Git commit asks for passphrase which I don't remember
- On Gitlab, is there a way to allow Maintaners to merge MRs even if some checks fail?
- Jenkins pipeline script: Accept merge request from Gitlab
- How to integrate GitLab code into SAP DataServices job?
- How to use dynamic value for start_in using environment variable in gitlab pipeline child job
- Replace React Variables in build folder before serving the build by express Server
- Gitlab CI/CD pipeline not destroying created Terraform created resources
- DevOps Preference: Point Solutions or Single Platform?
- GitLab release-job creates a release where asset is artifacts.zip instead of concrete file
- How to run particular jobs in GitLab CI/CD via GitLab API?
- How to start from a clean stage after maven release job fails in GitLab pipeline?
- Gitlab 16.10: The scheduler failed to assign job to the runner, please try again or contact system administrator
- Gitlab-runner cann't connect to gitlab server
Related Questions in GITLAB-API
- GitLab "Upload a File" API returns "file is invalid" after POST
- Rotating Gitlab's Service Account tokens with specified expiry
- how to trigger and pass parameters to a job in a gitlab ci/cd via gitlab api?
- GitLab option not available in Jenkins Create a Pipeline in Blue Ocean screen
- Retrieve Gitlab Group members which has been assign to other Gitlab Group as Group
- Copy project files in path and projects in child subgroups
- is it possible to invoke a gitlab ci/cd step via rest call?
- How to get updates from gitlab API if topics changed?
- Using the Gitlab API in Python, how do I retrieve a file from a specific commit
- Is it possible in gitlab to do 2 manual jobs of which only one can be run?
- How to add group of users to a project with api PUT request?
- With Gitlab, in the CI/CD pipeline, how can I dynamically create and save SSH key pairs as CI/CD project variables?
- Retrieving same variable from all files of a repo
- How to prevent a job to be not must be included in a gitlab
- What is Internal id in Gitlab webhook merge request event payload?
Related Questions in PYTHON-GITLAB
- Using the Gitlab API in Python, how do I retrieve a file from a specific commit
- add a comment to an existing issue in gitlab
- AttibuteError when trying to get personal_access_token when using python-gitlab library
- How to update a Branch using python-gitlab for Gitlab API?
- Get terraform aws provider version constraints of tf modules from a git monorepo (gitlab) with versions tag
- How to get the projects url by project id by using gitlab library in python
- Trigger Gitlab pipeline with own TRIGGER_PAYLOAD data using python-gitlab?
- Python Gitlab's creating commit functionality doesn't work if the file is renamed
- 403 Forbidden error when I tried to assign a user developer role using GitLab API through Python code
- Getting HTTP Error 403 Forbidden when making call to GitLab server using Python code
- Using label with python-gitlab
- Python_Gitlab How to extract string from the output of ProjectJob.trace API call
- Pushing picture to gitlab with python-gitlab
- Set should_remove_source_branch to true is not reflected
- Attempted to initialize RESTObject with a non-dictionary value when adding file to GitLab project using python-gitlab
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Look for include_diverged_commits_count: "true" (default is false) in the MR API: https://docs.gitlab.com/ee/api/merge_requests.html#get-single-mr.
The only downer (IMHO) is that this seems to be only available via the MR API, and so you need to first create a MR.