How to get the commit infor for pullrequest

Hi All,

I'm working with PullRequest and I'm using "PreReceiveRepositoryHook" interfece.

How can I get the commit information while I'm doing pullrequest from one branch to another.

I able to get the details while pusing but i need same for pull request.

urgent please..

Thanks&Regards

Anil.

2 answers

You cannot do this with a pre-receive hook. Take a look at this topic for advice on how to get this done.

Hi Balazs,

With PreReceiveRepositoryHook,RepositorySettingsValidator, I able to get the with this

public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse) {

}

I able to get the commit details.

And also with these AsyncPostReceiveRepositoryHook, RepositorySettingsValidator

public void postReceive(RepositoryHookContext context, Collection<RefChange> refChanges)
{

}

I able to get the commit details here as well.

But with RepositoryMergeRequestCheck, RepositorySettingsValidator

public void check(RepositoryMergeRequestCheckContext context)
{
// here im not able to get the commit info.
}

I need to get the commit info here becuse while i'm doing pullrequest this is excecuting so i need to update my ticet portals with some "pull request intiated " message.

With the AsyncPostReceiveRepositoryHook, RepositorySettingsValidator


public void postReceive(RepositoryHookContext context, Collection<RefChange> refChanges)

{

//here i able to get the commit details.

}

So, with PreRepositoryMergeHook i need to get the commit info while user clicks the pullrequest button in stash server.

Thanks&Regards

Anil

I have not (yet) used RepositoryMergeRequestCheck, but it seems from the documentation that RepositoryMergeRequestCheckContext.getMergeRequest().getPullRequest().getFromRef() gets you a ref to the branch which is about to be merged and then you can fish out the commits from there using CommitService.

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...

675 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