in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/gitlab/GitlabPublisher.java [334:358]
private String getBranchRefForApi(@Nullable String originalRef, @NotNull BuildRevision revision, @Nullable SBuildType buildType) {
if (originalRef == null) {
return null;
}
if (originalRef.startsWith(REFS_HEADS)) {
return originalRef.substring(REFS_HEADS.length());
}
if (originalRef.startsWith(REFS_TAGS)) {
return originalRef.substring(REFS_TAGS.length());
}
if (TeamCityProperties.getBooleanOrTrue(USE_REF_WHEN_PUBLISHING_STATUS_ON_MERGE_COMMITS_INTERNAL_PROP) &&
myPullRequestManager != null && buildType != null && originalRef.startsWith(REFS_MERGE_REQUESTS)) {
// this is a merge request branch, we need to find the corresponding source branch
List<PullRequest> pullRequests = myPullRequestManager.getCachedPullRequests(revision.getRoot(), buildType, originalRef);
if (!pullRequests.isEmpty()) {
String sourceBranchRef = pullRequests.get(0).getSourceBranchRef();
if (sourceBranchRef != null && sourceBranchRef.startsWith(REFS_HEADS)) {
return sourceBranchRef.substring(REFS_HEADS.length());
}
}
}
return null;
}