1

I want to get the list of commits since the last release, but since I have a lot of git repos to examine, I would like to do it via the bitbucket rest API instead of cloning each and every git repo I want to test.

If I do have a clone, my problem is simple:

#!/bin/bash

git tag | grep '<release-tag-regexp>' | sort <in-descending-order>' \
  | while read tag
    do
      tag_sha1="$(git rev-parse "$tag^{commit}")"
      ancestor="$(git merge-base HEAD $tag)"
      if [ $ancestor = $tag_sha1 ]
      then
        echo "Closest release tag is: $tag"
        exit 1
      fi
    done

 if [ $? -eq 0 ]
 then
   echo "No release tag found which is an ancestor of HEAD"
 fi

I wished bitbucket had a rest call for this query. As it looks, I seem to have no choice but to use the commit log and the tag list and construct a map myself.

Christian Goetze
  • 2,254
  • 3
  • 34
  • 51

1 Answers1

0

You're not able to get the closest tag to a given commit via the REST API. However, if you already have the tags then you can get the list of commits between two tags by using the commits REST API and passing through the since and until query params.

Kristy Hughes
  • 586
  • 1
  • 6
  • 10
  • I'll have to try if it does the right thing topologically, i.e. if it's the equivalent of `git log since..until` - but even if it does, it really doesn't help get me what I want: i.e. given any random branch, tell me what changed since the last release from that branch (or its parents).... – Christian Goetze May 23 '18 at 17:29