Can't detect cherry-picked vs. local user commits via REST API

There is an end case that I am trying to detect in our BitBucket Pre-Receive script. The case is quite simple. A developer creates a bugfix branch off of master and begins doing work. They perform some local commits then push their bugfix branch into BitBucket.

I want to determine if the user is creating a new commit or has cherry-picked an existing commit from another branch (previously committed and pushed to master).

For lack of a better approach I would like to use the REST API to check each commit hash to see if its been previously committed.

My calls to

http://<our bitbucket instance>/rest/api/1.0/users/testuser/repos/testrepo/commits/<commit hash>

should return a 404 for new commits.

When I type a random commit hash I get a 404 via CURL which is expected

When I type a previously committed hash I get valid commit details via CURL which is expected

When I iterate through the list of commits in a Pre-Receive hook all new and old commits are found via the REST call. Does BitBucket internalize all commits before the Pre-Receive hook is executed? Is there any other way to detect this case via a REST call?

0 answers

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

672 views 0 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot