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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

23,891 views 26 12
Join discussion

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