Skip to content

Commit d6e53db

Browse files
committed
refactory repository history check
1 parent c2b9fac commit d6e53db

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,26 @@ public boolean hasHistory(File file) {
614614
return false;
615615
}
616616

617+
if (!repositoryHasHistory(file, repo)) {
618+
return false;
619+
}
620+
621+
// This should return true for Annotate view.
622+
Configuration.RemoteSCM globalRemoteSupport = env.getRemoteScmSupported();
623+
boolean remoteSupported = ((globalRemoteSupport == RemoteSCM.ON)
624+
|| (globalRemoteSupport == RemoteSCM.UIONLY)
625+
|| (globalRemoteSupport == RemoteSCM.DIRBASED)
626+
|| !repo.isRemote());
627+
628+
if (!remoteSupported) {
629+
LOGGER.log(Level.FINEST, "not eligible to display history for ''{0}'' as repository {1} is remote " +
630+
"and the global setting is {2}", new Object[]{file, repo, globalRemoteSupport});
631+
}
632+
633+
return remoteSupported;
634+
}
635+
636+
private static boolean repositoryHasHistory(File file, Repository repo) {
617637
if (!repo.isWorking()) {
618638
LOGGER.log(Level.FINEST, "repository {0} for ''{1}'' is not working to check history presence",
619639
new Object[]{repo, file});
@@ -632,19 +652,7 @@ public boolean hasHistory(File file) {
632652
return false;
633653
}
634654

635-
// This should return true for Annotate view.
636-
Configuration.RemoteSCM globalRemoteSupport = env.getRemoteScmSupported();
637-
boolean remoteSupported = ((globalRemoteSupport == RemoteSCM.ON)
638-
|| (globalRemoteSupport == RemoteSCM.UIONLY)
639-
|| (globalRemoteSupport == RemoteSCM.DIRBASED)
640-
|| !repo.isRemote());
641-
642-
if (!remoteSupported) {
643-
LOGGER.log(Level.FINEST, "not eligible to display history for ''{0}'' as repository {1} is remote " +
644-
"and the global setting is {2}", new Object[]{file, repo, globalRemoteSupport});
645-
}
646-
647-
return remoteSupported;
655+
return true;
648656
}
649657

650658
/**

0 commit comments

Comments
 (0)