Absorb c.g.g.common.ProjectUtil into c.g.g.server.ProjectUtil

Both classes only contain one static method each, and are used only
in a few places.

Remove the one in c.g.g.common and move its method to the other one.

Change-Id: I8ae9affc75c8abe6d3341287b604f5d2fd752caf
This commit is contained in:
David Pursehouse
2019-01-23 23:12:16 +09:00
parent 296772f362
commit 7db054a948
4 changed files with 15 additions and 34 deletions

View File

@@ -1,32 +0,0 @@
// Copyright (C) 2013 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.common;
public class ProjectUtil {
public static String stripGitSuffix(String name) {
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.
//
name = name.substring(0, name.length() - 4);
while (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
}
return name;
}
private ProjectUtil() {}
}

View File

@@ -44,4 +44,17 @@ public class ProjectUtil {
return exists;
}
}
public static String stripGitSuffix(String name) {
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.
//
name = name.substring(0, name.length() - 4);
while (name.endsWith("/")) {
name = name.substring(0, name.length() - 1);
}
}
return name;
}
}

View File

@@ -17,9 +17,9 @@ package com.google.gerrit.server.args4j;
import static com.google.gerrit.util.cli.Localizable.localizable;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.ProjectUtil;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.ProjectUtil;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.permissions.ProjectPermission;

View File

@@ -19,7 +19,6 @@ import static java.util.Objects.requireNonNull;
import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.gerrit.common.ProjectUtil;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.api.projects.ConfigInput;
@@ -35,6 +34,7 @@ import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestCollectionCreateView;
import com.google.gerrit.extensions.restapi.TopLevelResource;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.ProjectUtil;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.config.AllUsersName;
import com.google.gerrit.server.config.ProjectOwnerGroupsProvider;