Inquisitor Shm Inquisitor Shm - 10 months ago 75
Git Question

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:


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?

Answer Source

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


"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:

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:

Condensed Git Graph for AUI-1546

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.