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
998 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
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
- python how to write list of lists to file
- Removing URL features from tokens in NLTK
- Optimizing for Social Leaderboards
- Python : Get size of string in bytes
- What is the code of the sorted function?
Related Questions in API
- SuiteCRM how to retrieve all account related contacts
- how do i submit a pastebin or pastee from an android app and get the url back
- BigCommerce PHP API delete Category which contains products
- Interact with chrome bookmarks outside of extensions
- purchase individual items and subscriptions in the same PayPal REST API transaction
- youtube api v3 insert comments
- Youtube api v3 duration
- Responding to an Office 365 event invite via REST
- Convert youtube video to mp3 using Quick MP3 API
- How to real-time monitor the emails?
- Laravel - Fractal - Using Find() in transformer file- is it correct or can it be done more efficiently?
- return data from a Azure API json
- Accessing Picasa Web API using PHP
- RAML multivalued form parameter
- TestFlight API and stats with as3
Related Questions in GITLAB
- I can push but not pull git
- Git first pull and push to master issue
- Can you create a project on GitLab using ssh?
- Adding A Certificate Authority in GitLab?
- GitLab shows deleted branches
- Files deleted with git filter-branch reappear after push and pull back
- Gitlab LDAP (Active Directory) Authentication without Server Side Access
- Cannot upgrade gitlab from 7.9.4
- GIT - Split working space by user (designer vs programmer)
- git diff not working on a bare repo, post-receive hook
- gitlab: Windows: How to use chmod and fix "Get Permission denied (publickey). fatal: Could not read from remote repository"
- git pull returns, fatal: protocol error: bad line length character: No s
- Custom post-receive hook with gitlab
- Installing GitLab CI Runner on Raspberry Pi 2 (Raspbian)
- From development to deployment with Git
Related Questions in GITLAB-API
- GitLab API - How to get private_token using GET with session parameter?
- Include submodules into source packages of releases
- Get gitlab parent project details in child project
- Get artifacts of included gitlab template
- How to add label when merge request is created on gitlab?
- Gitlab API : Get project's Events with python
- Importing git bundle into gitlab
- Assignee for issue not set on creation
- Gitlab api set CICD separated caches not working
- Multiline comment on merge request with GitLab REST API
- GitLab API: Create Job and run in runner
- How to retrieve all commits for a file in Gitlab
- merge_when_pipeline_succeeds is always set to false via API call
- Python_Gitlab How to extract string from the output of ProjectJob.trace API call
- Any workaround to access protected variables inside merge request pipeline?
Related Questions in PYTHON-GITLAB
- Set should_remove_source_branch to true is not reflected
- Pushing picture to gitlab with python-gitlab
- Python_Gitlab How to extract string from the output of ProjectJob.trace API call
- Using label with python-gitlab
- Getting HTTP Error 403 Forbidden when making call to GitLab server using Python code
- 403 Forbidden error when I tried to assign a user developer role using GitLab API through Python code
- Python Gitlab's creating commit functionality doesn't work if the file is renamed
- python-gitlab : How to list all issues in a specific milestone
- gitlab CLI - get project variable value
- python-gitlab mocking ProjectCommit objects API V4
- Python-GitLab Unprotect master
- What does => mean in python output and how can I get the right side value
- Python-gitlab API V4
- how to process output from python-gitlab api requests
- How to update a protected branch in 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 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.