How to get the commit infor for pullrequest

anil kumar April 22, 2014

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

0 votes
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2014

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.

0 votes
Balázs Szakmáry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 22, 2014

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

anil kumar April 22, 2014

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events