简体   繁体   中英

Bitbucket REST interface and GIT; how to get a log history between two tags from a branch

I am building an app to which requires all the commit comments from git commits against a branch on remote origin. Our repository is hosted on a BitBucket server and is a Git repository.

I have looked over the Bitbucket (Stash) REST api and I can bring back the git comments by browsing the commits, something like this:

  https://mybitbucket.local/rest/api/1.0/projects/myslug/repos/myproduct/commits?limit=1000&branch=mybranch

What I need now, just to make it more efficient, is a mechanism to request the content from just between two tags. Is this possible? I imagine providing two tags as parameters, like &fromTag=X&toTag=y...

I cannot find this, and the documentation is a little sparse... :(

Is there a way?

See Bitbucket Server's " compare/commits " REST API call:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/compare/commits

"Gets the commits accessible from the {@code from} commit but not in the {@code to} commit."

Here's an example call against my demo server (probably need to login as user "test" with pass "test" first) that returns with 5 commits that can be seen from a6e64f4fd0e but are not visible from master :

http://vm.bit-booster.com/bitbucket/rest/api/1.0/projects/BB/repos/aui/compare/commits?from=a6e64f4fd0e&to=master&limit=100

Since you're using Bitbucket/Stash, you might be interested in my Bit-Booster Commit Graph and More add-on to visually verify the correct commits are being returned, like so :

AUI-1546的简明Git图

In this case the 5 commits that match "AUI-1546" are the ones my example "commits/compare" REST API call above is returning. You can see quite clearly on this graph how they are precisely the 5 commits that are 1.) accessible from a6e64f4fd0e and 2.) not accessible from master .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM