Skip to content

Commit

Permalink
use headBranchName as a fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhee17 committed Jun 13, 2024
1 parent 804b8c9 commit 6441bfb
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ void mirrorRemoteToLocal(
mirrorStatePath, "{ \"sourceRevision\": \"" + headCommitId.name() + "\" }"));
// Construct the log message and log.
final String branchName = getRemoteBranchName(headBranchRef);
summary = "Mirror " + abbrId + ", " + remoteRepoUri() + '#' + branchName +
" to the repository '" + localRepo().name() + '\'';
summary = "Mirror " + abbrId + ", '" + remoteRepoUri() + '#' + branchName +
"' to the repository '" + localRepo().name() + '\'';
final RevCommit headCommit = revWalk.parseCommit(headCommitId);
detail = generateCommitDetail(headCommit);
logger.info(summary);
Expand Down Expand Up @@ -725,13 +725,15 @@ static void updateRef(org.eclipse.jgit.lib.Repository jGitRepository, RevWalk re
}

private String getRemoteBranchName(Ref headBranchRef) {
if (remoteBranch() != null && !remoteBranch().isEmpty()) {
return remoteBranch();
final String remoteBranch = remoteBranch();
if (remoteBranch != null && !remoteBranch.isEmpty()) {
return remoteBranch;
}
if (headBranchRef.getName().startsWith(Constants.R_HEADS)) {
return headBranchRef.getName().substring(Constants.R_HEADS.length());
final String headBranchName = headBranchRef.getName();
if (headBranchName.startsWith(Constants.R_HEADS)) {
return headBranchName.substring(Constants.R_HEADS.length());
}
return "";
return headBranchName;
}

private static final class InsertText extends PathEdit {
Expand Down

0 comments on commit 6441bfb

Please sign in to comment.