diff options
-rw-r--r-- | pom.xml | 6 | ||||
-rw-r--r-- | src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java | 3 | ||||
-rw-r--r-- | src/main/resources/Documentation/config.md | 14 |
3 files changed, 19 insertions, 4 deletions
@@ -82,6 +82,12 @@ limitations under the License. <version>4.8.1</version> <scope>test</scope> </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.4</version> + </dependency> </dependencies> <repositories> diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java index fe5969c..4271dc9 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/Destination.java @@ -44,6 +44,7 @@ import com.google.inject.Provides; import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.servlet.RequestScoped; +import org.apache.commons.io.FilenameUtils; import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Ref; @@ -429,6 +430,8 @@ class Destination { name = name.replace("/", "-"); } else if(remoteNameStyle.equals("underscore")) { name = name.replace("/", "_"); + } else if (remoteNameStyle.equals("basenameOnly")) { + name = FilenameUtils.getBaseName(name); } else if (!remoteNameStyle.equals("slash")) { ReplicationQueue.log.debug(String.format( "Unknown remoteNameStyle: %s, falling back to slash", remoteNameStyle)); diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md index 0532350..5205025 100644 --- a/src/main/resources/Documentation/config.md +++ b/src/main/resources/Documentation/config.md @@ -221,16 +221,22 @@ remote.NAME.mirror By default, false, do not remove remote branches. remote.NAME.remoteNameStyle -: Slashes in the `${name}` placeholder are replaced with either - dashes or underscores. +: Provides possibilities to influence the name of the target + repository, e.g. by replacing slashes in the `${name}` + placeholder. Github and Gitorious do not permit slashes "/" in repository names and changes this to dashes "-" at repository creation - time. If set to "dash," this changes slashes to dashes in the + time. If set to "dash", this changes slashes to dashes in the repository name. If set to "underscore", this changes slashes to underscores in the repository name. - By default, "slash," remote name will contain slashes as they + Option "basenameOnly" makes `${name}` to be only the basename + (the part after the last slash) of the repository path on the + Gerrit server, e.g. `${name}` of `foo/bar/my-repo.git` would + be `my-repo`. + + By default, "slash" remote name will contain slashes as they do in Gerrit. <a name="remote.NAME.projects">remote.NAME.projects</a> |