mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
[vcs] IJPL-72638 refactoring: extract method.
GitOrigin-RevId: c6c7fd88c5cc2d663e3673ce00c8c5df0ef494a1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
af10d1b315
commit
56d136bb42
@@ -167,16 +167,8 @@ public final class GitBranchUtil {
|
||||
public static @Nls @NotNull String getDisplayableBranchText(@NotNull GitRepository repository,
|
||||
@NotNull Function<@NotNull @NlsSafe String, @NotNull @NlsSafe String> branchNameTruncator) {
|
||||
GitRepository.State state = repository.getState();
|
||||
if (state == GitRepository.State.DETACHED) {
|
||||
String currentRevision = repository.getCurrentRevision();
|
||||
if (currentRevision != null) {
|
||||
return DvcsUtil.getShortHash(currentRevision);
|
||||
}
|
||||
else {
|
||||
LOG.warn(String.format("Current revision is null in DETACHED state. isFresh: %s", repository.isFresh()));
|
||||
return GitBundle.message("git.status.bar.widget.text.unknown");
|
||||
}
|
||||
}
|
||||
String currentRevision = getDetachedPresentableText(repository, state);
|
||||
if (currentRevision != null) return currentRevision;
|
||||
|
||||
GitBranch branch = repository.getCurrentBranch();
|
||||
String branchName = (branch == null ? "" : branchNameTruncator.apply(branch.getName()));
|
||||
@@ -198,6 +190,21 @@ public final class GitBranchUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Nls
|
||||
private static @Nullable String getDetachedPresentableText(@NotNull GitRepository repository, GitRepository.State state) {
|
||||
if (state == GitRepository.State.DETACHED) {
|
||||
String currentRevision = repository.getCurrentRevision();
|
||||
if (currentRevision != null) {
|
||||
return DvcsUtil.getShortHash(currentRevision);
|
||||
}
|
||||
else {
|
||||
LOG.warn(String.format("Current revision is null in DETACHED state. isFresh: %s", repository.isFresh()));
|
||||
return GitBundle.message("git.status.bar.widget.text.unknown");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Prefer {@link #guessWidgetRepository(Project)} or {@link #guessRepositoryForOperation(Project, DataContext)}.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user