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

@@ -64,6 +64,8 @@ OPTIONS
--files::
Support for listing files with patch sets and their
attributes (ADDED, MODIFIED, DELETED, RENAMED, COPIED).
Note that this option requires either the --current-patch-set
or the --patch-sets option in order to give any file information.
--comments::
Include comments for all changes. If combined with the

View File

@@ -100,10 +100,18 @@ public class QueryProcessor {
includePatchSets = on;
}
public boolean getIncludePatchSets() {
return includePatchSets;
}
public void setIncludeCurrentPatchSet(boolean on) {
includeCurrentPatchSet = on;
}
public boolean getIncludeCurrentPatchSet() {
return includeCurrentPatchSet;
}
public void setIncludeApprovals(boolean on) {
includeApprovals = on;
}
@@ -116,6 +124,10 @@ public class QueryProcessor {
includeFiles = on;
}
public boolean getIncludeFiles() {
return includeFiles;
}
public void setIncludeCommitMessage(boolean on) {
includeCommitMessage = on;
}

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++) {