Skip to content

Commit

Permalink
Get default branch in case use doesn't specify
Browse files Browse the repository at this point in the history
  • Loading branch information
thachlp committed Mar 23, 2024
1 parent 20772a8 commit f05407b
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ void mirrorRemoteToLocal(
changes.put(mirrorStatePath, Change.ofJsonUpsert(
mirrorStatePath, "{ \"sourceRevision\": \"" + headCommitId.name() + "\" }"));
// Construct the log message and log.
summary = "Mirror " + abbrId + ", " + remoteRepoUri() +
(remoteBranch() != null ? '#' + remoteBranch() : "") +
final String branchName = getRemoteBranchName(headBranchRef);
summary = "Mirror " + abbrId + ", " + remoteRepoUri() + '#' + branchName +
" to the repository '" + localRepo().name() + '\'';
final RevCommit headCommit = revWalk.parseCommit(headCommitId);
detail = generateCommitDetail(headCommit);
Expand Down Expand Up @@ -724,6 +724,16 @@ static void updateRef(org.eclipse.jgit.lib.Repository jGitRepository, RevWalk re
}
}

private String getRemoteBranchName(Ref headBranchRef) {
if (remoteBranch() != null && !remoteBranch().isEmpty()) {
return remoteBranch();

Check warning on line 729 in server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/AbstractGitMirror.java

View check run for this annotation

Codecov / codecov/patch

server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/AbstractGitMirror.java#L729

Added line #L729 was not covered by tests
}
if (headBranchRef.getName().startsWith(Constants.R_HEADS)) {
return headBranchRef.getName().substring(Constants.R_HEADS.length());
}
return "";

Check warning on line 734 in server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/AbstractGitMirror.java

View check run for this annotation

Codecov / codecov/patch

server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/AbstractGitMirror.java#L734

Added line #L734 was not covered by tests
}

private static final class InsertText extends PathEdit {
private final ObjectInserter inserter;
private final String text;
Expand Down

0 comments on commit f05407b

Please sign in to comment.