Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to check on preceive hook merge commit?

Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2017

Hi! 

 

We have upgraded Bitbucket to 5.3. from 4.14 version. 

And now our preceive hook can match merge commits.

private final Pattern mergeBranchPattern =
Pattern.compile("Merge.*");
boolean isMerge = false;
String mergeBranch = "";
Collection<MinimalCommit> parents = cs.getParents();
if (parents.size() > 1) {
Matcher m = mergeBranchPattern.matcher(comment);
if (m.find()) {
isMerge = true;
mergeBranch = m.group();
} else {
rejects.add("Merge commit message should start from word \"Merge...\"");
return rejects;
}

 

Could you help which changes was on 5.3. version for merge commits? 

Thank you

 

Additional info about Merge strategies: 

Merge commit--no-ff

 

BR,

Gonchik

 

1 answer

1 accepted

0 votes
Answer accepted
Gonchik Tsymzhitov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 25, 2017

This condition is helped 

private final String pullRequestEvent ="pull-request-merge";
String eventTrigger = repositoryHookRequest.getTrigger().getId();
if (eventTrigger.equalsIgnoreCase(pullRequestEvent)) {
log.info("Excepted Merge Pull request");
return RepositoryHookResult.accepted();
}

  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events