Fix parameter checking on ls-projects command
The command `ls-projects -t` always fails with the error: Fatal: --tree and --show-branch options are not compatible. This is because when there are no --show-branch options passed, the call to `getShowBranch` still returns an empty list, which causes `getShowBranch() != null` to be true, and results in the error condition. Update the condition to first check if the list is null, and then if it's empty. The error only needs to be emitted if the list is not null and not empty. Change-Id: Ia4db17adaa814328da6eb88874088bbe3b6acbe6
This commit is contained in:
parent
6eed43f008
commit
6a4b4d27e3
@ -21,6 +21,8 @@ import com.google.inject.Inject;
|
||||
|
||||
import org.apache.sshd.server.Environment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandMetaData(name = "ls-projects", descr = "List projects visible to the caller")
|
||||
final class ListProjectsCommand extends BaseCommand {
|
||||
@Inject
|
||||
@ -33,7 +35,8 @@ final class ListProjectsCommand extends BaseCommand {
|
||||
public void run() throws Exception {
|
||||
parseCommandLine(impl);
|
||||
if (!impl.getFormat().isJson()) {
|
||||
if (impl.isShowTree() && (impl.getShowBranch() != null)) {
|
||||
List<String> showBranch = impl.getShowBranch();
|
||||
if (impl.isShowTree() && (showBranch != null) && !showBranch.isEmpty()) {
|
||||
throw new UnloggedFailure(1, "fatal: --tree and --show-branch options are not compatible.");
|
||||
}
|
||||
if (impl.isShowTree() && impl.isShowDescription()) {
|
||||
|
Loading…
Reference in New Issue
Block a user