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

This widget could not be displayed.

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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,199 views 8 10
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