Polish the error message about wrong project name
If there is not project 'wrongname.git' on disk, below command 'git push ssh://review/wrongname.git HEAD:refs/for/master' will get an error: 'fatal: '/wrongname.git': not a Gerrit project' This patch polish it to be: 'fatal: 'wrongname.git': is not a Gerrit project'. Change-Id: Iab1430758c73903237d91f814392b46767c73a18
This commit is contained in:
		@@ -20,6 +20,7 @@ import com.google.gerrit.server.project.ProjectControl;
 | 
				
			|||||||
import com.google.inject.Inject;
 | 
					import com.google.inject.Inject;
 | 
				
			||||||
import com.google.inject.assistedinject.Assisted;
 | 
					import com.google.inject.assistedinject.Assisted;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jgit.lib.Constants;
 | 
				
			||||||
import org.kohsuke.args4j.CmdLineException;
 | 
					import org.kohsuke.args4j.CmdLineException;
 | 
				
			||||||
import org.kohsuke.args4j.CmdLineParser;
 | 
					import org.kohsuke.args4j.CmdLineParser;
 | 
				
			||||||
import org.kohsuke.args4j.OptionDef;
 | 
					import org.kohsuke.args4j.OptionDef;
 | 
				
			||||||
@@ -42,23 +43,12 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
 | 
				
			|||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
  public final int parseArguments(final Parameters params)
 | 
					  public final int parseArguments(final Parameters params)
 | 
				
			||||||
      throws CmdLineException {
 | 
					      throws CmdLineException {
 | 
				
			||||||
    final String token = params.getParameter(0);
 | 
					    String projectName = params.getParameter(0);
 | 
				
			||||||
    String projectName = token;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while (projectName.endsWith("/")) {
 | 
					    while (projectName.endsWith("/")) {
 | 
				
			||||||
      projectName = projectName.substring(0, projectName.length() - 1);
 | 
					      projectName = projectName.substring(0, projectName.length() - 1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (projectName.endsWith(".git")) {
 | 
					 | 
				
			||||||
      // Be nice and drop the trailing ".git" suffix, which we never keep
 | 
					 | 
				
			||||||
      // in our database, but clients might mistakenly provide anyway.
 | 
					 | 
				
			||||||
      //
 | 
					 | 
				
			||||||
      projectName = projectName.substring(0, projectName.length() - 4);
 | 
					 | 
				
			||||||
      while (projectName.endsWith("/")) {
 | 
					 | 
				
			||||||
        projectName = projectName.substring(0, projectName.length() - 1);
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    while (projectName.startsWith("/")) {
 | 
					    while (projectName.startsWith("/")) {
 | 
				
			||||||
      // Be nice and drop the leading "/" if supplied by an absolute path.
 | 
					      // Be nice and drop the leading "/" if supplied by an absolute path.
 | 
				
			||||||
      // We don't have a file system hierarchy, just a flat namespace in
 | 
					      // We don't have a file system hierarchy, just a flat namespace in
 | 
				
			||||||
@@ -68,12 +58,25 @@ public class ProjectControlHandler extends OptionHandler<ProjectControl> {
 | 
				
			|||||||
      projectName = projectName.substring(1);
 | 
					      projectName = projectName.substring(1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    String nameWithoutSuffix = projectName;
 | 
				
			||||||
 | 
					    if (nameWithoutSuffix.endsWith(Constants.DOT_GIT_EXT)) {
 | 
				
			||||||
 | 
					      // Be nice and drop the trailing ".git" suffix, which we never keep
 | 
				
			||||||
 | 
					      // in our database, but clients might mistakenly provide anyway.
 | 
				
			||||||
 | 
					      //
 | 
				
			||||||
 | 
					      nameWithoutSuffix = nameWithoutSuffix.substring(0, //
 | 
				
			||||||
 | 
					          nameWithoutSuffix.length() - Constants.DOT_GIT_EXT.length());
 | 
				
			||||||
 | 
					      while (nameWithoutSuffix.endsWith("/")) {
 | 
				
			||||||
 | 
					        nameWithoutSuffix =
 | 
				
			||||||
 | 
					            nameWithoutSuffix.substring(0, nameWithoutSuffix.length() - 1);
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    final ProjectControl control;
 | 
					    final ProjectControl control;
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      Project.NameKey nameKey = new Project.NameKey(projectName);
 | 
					      Project.NameKey nameKey = new Project.NameKey(nameWithoutSuffix);
 | 
				
			||||||
      control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
 | 
					      control = projectControlFactory.validateFor(nameKey, ProjectControl.OWNER | ProjectControl.VISIBLE);
 | 
				
			||||||
    } catch (NoSuchProjectException e) {
 | 
					    } catch (NoSuchProjectException e) {
 | 
				
			||||||
      throw new CmdLineException(owner, "'" + token + "': not a Gerrit project");
 | 
					      throw new CmdLineException(owner, "'" + projectName + "': is not a Gerrit project");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    setter.addValue(control);
 | 
					    setter.addValue(control);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user