Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Bitbucket API - Determine if two commit are related?

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

0 votes

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

2,558 views 1 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you