Skip to content

Commit 18d0c95

Browse files
author
Vladimir Kotal
committed
remove repository listing in indexer
1 parent 09dc233 commit 18d0c95

File tree

14 files changed

+25
-61
lines changed

14 files changed

+25
-61
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/index/Indexer.java

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public final class Indexer {
9595
private static final Indexer index = new Indexer();
9696
private static Configuration cfg = null;
9797
private static boolean checkIndexVersion = false;
98-
private static boolean listRepos = false;
9998
private static boolean runIndex = true;
10099
private static boolean optimizedChanged = false;
101100
private static boolean addProjects = false;
@@ -313,15 +312,10 @@ public static void main(String[] argv) {
313312
LOGGER.log(Level.INFO, "Indexer version {0} ({1})",
314313
new Object[]{Info.getVersion(), Info.getRevision()});
315314

316-
// Get history first.
315+
// Create history cache first.
317316
getInstance().prepareIndexer(env, searchRepositories, addProjects,
318317
defaultProjects,
319-
listFiles, createDict, runIndex, subFiles, new ArrayList<>(repositories),
320-
listRepos);
321-
322-
if (listRepos) {
323-
return;
324-
}
318+
listFiles, createDict, runIndex, subFiles, new ArrayList<>(repositories));
325319

326320
// And now index it all.
327321
if (runIndex || (optimizedChanged && env.isOptimizeDatabase())) {
@@ -551,10 +545,6 @@ public static String[] parseOptions(String[] argv) throws ParseException {
551545
cfg.setAllowLeadingWildcard((Boolean)v);
552546
});
553547

554-
parser.on("--listRepos", "List all repository paths and exit.").Do(v -> {
555-
listRepos = true;
556-
});
557-
558548
parser.on("-m", "--memory", "=number", Double.class,
559549
"Amount of memory that may be used for buffering added documents and",
560550
"deletions before they are flushed to the directory (default " + Configuration.defaultRamBufferSize + "MB).",
@@ -890,10 +880,9 @@ public void prepareIndexer(RuntimeEnvironment env,
890880
boolean listFiles,
891881
boolean createDict,
892882
List<String> subFiles,
893-
List<String> repositories,
894-
boolean listRepoPaths) throws IndexerException, IOException {
883+
List<String> repositories) throws IndexerException, IOException {
895884
prepareIndexer(env, searchRepositories, addProjects, defaultProjects, listFiles, createDict, true,
896-
subFiles, repositories, listRepoPaths);
885+
subFiles, repositories);
897886
}
898887

899888
/**
@@ -915,7 +904,6 @@ public void prepareIndexer(RuntimeEnvironment env,
915904
* @param createHistoryCache create history cache flag
916905
* @param subFiles list of directories
917906
* @param repositories list of repositories
918-
* @param listRepoPaths print repository paths to standard output
919907
* @throws IndexerException indexer exception
920908
* @throws IOException I/O exception
921909
*/
@@ -928,8 +916,7 @@ public void prepareIndexer(RuntimeEnvironment env,
928916
boolean createDict,
929917
boolean createHistoryCache,
930918
List<String> subFiles,
931-
List<String> repositories,
932-
boolean listRepoPaths) throws IndexerException, IOException {
919+
List<String> repositories) throws IndexerException, IOException {
933920

934921
if (env.getDataRootPath() == null) {
935922
throw new IndexerException("ERROR: Please specify a DATA ROOT path");
@@ -979,30 +966,12 @@ public void prepareIndexer(RuntimeEnvironment env,
979966
}
980967
}
981968

982-
if (searchRepositories || listRepoPaths) {
969+
if (searchRepositories) {
983970
LOGGER.log(Level.INFO, "Scanning for repositories...");
984971
Statistics stats = new Statistics();
985972
env.setRepositories(env.getSourceRootPath());
986973
stats.report(LOGGER, String.format("Done scanning for repositories, found %d repositories",
987974
env.getRepositories().size()));
988-
989-
if (listRepoPaths) {
990-
List<RepositoryInfo> repos = env.getRepositories();
991-
String prefix = env.getSourceRootPath();
992-
if (listRepoPaths) {
993-
if (repos.isEmpty()) {
994-
System.out.println("No repositories found.");
995-
return;
996-
}
997-
System.out.println("Repositories in " + prefix + ":");
998-
for (RepositoryInfo info : env.getRepositories()) {
999-
String dir = info.getDirectoryName();
1000-
System.out.println(String.format("%s (%s)", dir.substring(prefix.length()), info.getType()));
1001-
}
1002-
}
1003-
1004-
return;
1005-
}
1006975
}
1007976

1008977
if (listFiles) {

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/executables/JarAnalyzerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static void setUpClass() throws Exception {
8585
IndexChangedListener progress = new DefaultIndexChangedListener();
8686
Indexer.getInstance().prepareIndexer(env, true, true,
8787
new TreeSet<>(Collections.singletonList("/c")),
88-
false, false, null, null, false);
88+
false, false, null, null);
8989

9090
Indexer.getInstance().doIndexerExecution(true, null, progress);
9191

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexDatabaseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static void setUpClass() throws Exception {
8888
Indexer indexer = Indexer.getInstance();
8989
indexer.prepareIndexer(
9090
env, true, true, new TreeSet<>(Arrays.asList(new String[]{"/c"})),
91-
false, false, null, null, false);
91+
false, false, null, null);
9292
indexer.doIndexerExecution(true, null, null);
9393
}
9494

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexVersionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void testIndexVersion(boolean projectsEnabled, List<String> subFiles) th
9191
env.setHistoryEnabled(false);
9292
env.setProjectsEnabled(projectsEnabled);
9393
Indexer.getInstance().prepareIndexer(env, true, true, null,
94-
false, false, null, null, false);
94+
false, false, null, null);
9595
Indexer.getInstance().doIndexerExecution(true, null, null);
9696

9797
IndexVersion.check(subFiles);

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexerRepoTest.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ private void testPerProjectHistory(boolean globalOn) throws IndexerException, IO
142142
false, // don't list files
143143
false, // don't create dictionary
144144
null, // subFiles - not needed since we don't list files
145-
null, // repositories - not needed when not refreshing history
146-
false); // don't list repos
145+
null); // repositories - not needed when not refreshing history
147146

148147
File repoRoot = new File(env.getSourceRootFile(), "git");
149148
File fileInRepo = new File(repoRoot, "main.c");
@@ -207,10 +206,9 @@ public void testSymlinks() throws IndexerException, IOException {
207206
false, // don't list files
208207
false, // don't create dictionary
209208
null, // subFiles - not needed since we don't list files
210-
null, // repositories - not needed when not refreshing history
211-
false); // don't list repos
209+
null); // repositories - not needed when not refreshing history
212210

213-
// Check the respository paths.
211+
// Check the repository paths.
214212
List<RepositoryInfo> repos = env.getRepositories();
215213
assertEquals(repos.size(), 1);
216214
RepositoryInfo repo = repos.get(0);

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexerTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void testIndexGeneration() throws Exception {
121121
env.setDataRoot(repository.getDataRoot());
122122
env.setHistoryEnabled(false);
123123
Indexer.getInstance().prepareIndexer(env, true, true, new TreeSet<>(Collections.singletonList("/c")),
124-
false, false, null, null, false);
124+
false, false, null, null);
125125
Indexer.getInstance().doIndexerExecution(true, null, null);
126126
}
127127

@@ -158,8 +158,7 @@ public void testRescanProjects() throws Exception {
158158
false, // don't list files
159159
false, // don't create dictionary
160160
null, // subFiles - not needed since we don't list files
161-
null, // repositories - not needed when not refreshing history
162-
false); // don't list repos
161+
null); // repositories - not needed when not refreshing history
163162

164163
List<Project> newProjects = env.getProjectList();
165164

@@ -486,7 +485,7 @@ public void testDefaultProjectsSingleProject() throws Exception {
486485
Indexer.getInstance().prepareIndexer(env, true, true, new TreeSet<>(Arrays.asList(new String[]{
487486
Paths.get("/c").toString()
488487
})),
489-
false, false, null, null,false);
488+
false, false, null, null);
490489
assertEquals(1, env.getDefaultProjects().size());
491490
assertEquals(new TreeSet<>(Arrays.asList(new String[]{"c"})),
492491
env.getDefaultProjects().stream().map((Project p) -> p.getName()).collect(Collectors.toSet()));
@@ -512,7 +511,7 @@ public void testDefaultProjectsNonExistent() throws Exception {
512511
Paths.get("/data").toString(),
513512
Paths.get("/no-project-x32ds1").toString()
514513
})),
515-
false, false, null, null, false);
514+
false, false, null, null);
516515
assertEquals(4, env.getDefaultProjects().size());
517516
assertEquals(new TreeSet<>(Arrays.asList(new String[]{"lisp", "pascal", "perl", "data"})),
518517
env.getDefaultProjects().stream().map((Project p) -> p.getName()).collect(Collectors.toSet()));
@@ -536,7 +535,7 @@ public void testDefaultProjectsAll() throws Exception {
536535
Paths.get("__all__").toString(),
537536
Paths.get("/no-project-x32ds1").toString()
538537
})),
539-
false, false, null, null, false);
538+
false, false, null, null);
540539
Set<String> projects = new TreeSet<>(Arrays.asList(new File(repository.getSourceRoot()).list()));
541540
assertEquals(projects.size(), env.getDefaultProjects().size());
542541
assertEquals(projects, env.getDefaultProjects().stream().map((Project p) -> p.getName()).collect(Collectors.toSet()));

opengrok-indexer/src/test/java/org/opengrok/indexer/search/SearchEngineTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static void setUpClass() throws Exception {
7575
env.setHistoryEnabled(false);
7676
Indexer.getInstance().prepareIndexer(env, true, true,
7777
new TreeSet<>(Collections.singletonList("/c")),
78-
false, false, null, null, false);
78+
false, false, null, null);
7979
Indexer.getInstance().doIndexerExecution(true, null, null);
8080

8181

opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/SearchAndContextFormatterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public static void setUpClass() throws Exception {
8989
env.setHistoryEnabled(false);
9090
Indexer.getInstance().prepareIndexer(env, true, true,
9191
new TreeSet<>(Collections.singletonList("/c")),
92-
false, false, null, null, false);
92+
false, false, null, null);
9393
Indexer.getInstance().doIndexerExecution(true, null, null);
9494

9595
configFile = File.createTempFile("configuration", ".xml");

opengrok-indexer/src/test/java/org/opengrok/indexer/search/context/SearchAndContextFormatterTest2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static void setUpClass() throws Exception {
128128
env.setHistoryEnabled(false);
129129
Indexer.getInstance().prepareIndexer(env, true, true,
130130
new TreeSet<>(Collections.singletonList("/c")),
131-
false, false, null, null, false);
131+
false, false, null, null);
132132

133133
Project proj1 = env.getProjects().get(SYMLINK1);
134134
assertNotNull("symlink1 project", proj1);

opengrok-indexer/src/test/java/org/opengrok/indexer/web/SearchHelperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private void reindex() throws Exception {
7676

7777
Indexer.getInstance().prepareIndexer(env, true, true,
7878
new TreeSet<>(Collections.singletonList("/c")),
79-
false, false, null, null, false);
79+
false, false, null, null);
8080
Indexer.getInstance().doIndexerExecution(true, null, null);
8181
}
8282

0 commit comments

Comments
 (0)