Drop the user provided project name's trailing '.git' suffix
After a new project is created successfully Gerrit will prepare the new project's general information link, if the project name has trailing ".git" suffix the link will be different with that in project list page and in some corner case of creating new project like 'p.git.git' the link will not work. Change-Id: I451b0db20233159cadaca14ffdbcdf2bfbe23e9c
This commit is contained in:
@@ -46,6 +46,8 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwtexpui.globalkey.client.NpTextBox;
|
||||
import com.google.gwtjsonrpc.common.VoidResult;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
|
||||
public class CreateProjectScreen extends Screen {
|
||||
private Grid grid;
|
||||
private NpTextBox project;
|
||||
@@ -235,8 +237,22 @@ public class CreateProjectScreen extends Screen {
|
||||
new GerritCallback<VoidResult>() {
|
||||
@Override
|
||||
public void onSuccess(VoidResult result) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
History.newItem(Dispatcher.toProjectAdmin(new Project.NameKey(
|
||||
projectName), ProjectScreen.INFO));
|
||||
nameWithoutSuffix), ProjectScreen.INFO));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user