The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Bitbucket API - Determine if two commit are related?

Donny Liang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 22, 2021

With the Bitbucket cloud API, is there a way to determine if two commits are related to each other (one is a parent of the other)?

I currently don't see a query/API endpoint that would match this type of information I'm looking for.

In the end, I want to grab all tags associated with child commits of a specific commit. Currently, I can get a list of all commits with tags since a commit but I will need a way to determine if the commits are related to my base commit.

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 24, 2021

Hi @Donny Liang  and welcome to the community.

This API endpoint will show you the parent(s) of a certain commit. However, based on your description, it looks that you want to find whether a commit is an ancestor of another one, and not just a direct parent, is that right?

I don't believe that this is possible via the API. You could use the git merge-base command in a clone of a repo, which provides the --is-ancestor option. The following command:

git merge-base --is-ancestor commit-A commit-B; echo $?

will return 0 if commit-A is an ancestor of commit-B and 1 if it's not an ancestor.

Kind regards,
Theodora

TAGS
AUG Leaders

Atlassian Community Events