Fix ProjectUtil

Cannot reference JGit classes from this package if the code is
called from UI code. The commit message that added this class said
exactly that, but failed to take its own advice.

Change-Id: Ib90324d653c3ca0d4aad5c635a4771596754c55b
This commit is contained in:
Shawn Pearce
2013-02-19 09:18:18 -08:00
parent 4b15db9c38
commit ee7ff53cbb

View File

@@ -14,23 +14,20 @@
package com.google.gerrit.common;
import org.eclipse.jgit.lib.Constants;
public class ProjectUtil {
public static String stripGitSuffix(String name) {
String nameWithoutSuffix = name;
if (nameWithoutSuffix.endsWith(Constants.DOT_GIT_EXT)) {
if (name.endsWith(".git")) {
// 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);
name = name.substring(0, name.length() - 4);
while (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
}
return nameWithoutSuffix;
return name;
}
private ProjectUtil() {
}
}