Error message when using gerrit query --files without patch set info.

If --files is set but neither --patch-sets nor --current-patch-set
is set, the query goes through, but no file information is in the
response. Added an error so that it is clearer how the --files
option is supposed to be used.

Change-Id: I2a3d9bf4850a9c48a7dee16535ecbbf08904a290
This commit is contained in:
thomas.westling
2011-12-29 16:34:45 +01:00
committed by Gustaf Lundh
parent a3f73aab40
commit 5a4d61b4db
3 changed files with 22 additions and 0 deletions

View File

@@ -76,11 +76,19 @@ class Query extends BaseCommand {
public void run() throws Exception {
processor.setOutput(out, QueryProcessor.OutputFormat.TEXT);
parseCommandLine();
verifyCommandLine();
processor.query(join(query, " "));
}
});
}
private void verifyCommandLine() throws UnloggedFailure {
if (processor.getIncludeFiles() &&
!(processor.getIncludePatchSets() || processor.getIncludeCurrentPatchSet())) {
throw new UnloggedFailure(1, "--files option needs --patch-sets or --current-patch-set");
}
}
private static String join(List<String> list, String sep) {
StringBuilder r = new StringBuilder();
for (int i = 0; i < list.size(); i++) {