Support an extra command for ssh command
This would be useful to add an extra command like initializing submodules.
Change-Id: If418279493e8556a8176a8b828c5edfc9f88e997
diff --git a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
index a0ed759..65f9f54 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/download/command/CloneWithCommitMsgHook.java
@@ -29,6 +29,7 @@
private static final String TARGET = " `git rev-parse --git-dir`/";
private final String configCommand;
+ private final String extraCommand;
private final SshScheme sshScheme;
private final Provider<CurrentUser> userProvider;
@@ -36,6 +37,7 @@
CloneWithCommitMsgHook(
@GerritServerConfig Config config, SshScheme sshScheme, Provider<CurrentUser> userProvider) {
this.configCommand = config.getString("gerrit", null, "installCommitMsgHookCommand");
+ this.extraCommand = config.getString("gerrit", null, "installCommitExtraCommand");
this.sshScheme = sshScheme;
this.userProvider = userProvider;
}
@@ -77,6 +79,9 @@
.append(projectName)
.append("/.git/hooks/");
+ if (extraCommand != null) {
+ b.append(" && (cd ").append(projectName).append(" && ").append(extraCommand).append(")");
+ }
return b.toString();
}
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index bcd27a9..3781f9e 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -87,3 +87,25 @@
allowTipSHA1InWant = true
By default `false`.
+
+
+### <a id="gerrit">Section gerrit</a>
+
+```
+[gerrit]
+ installCommitMsgHookCommand = command
+ installCommitExtraCommand = command
+```
+
+<a id="gerrit.installCommitMsgHookCommand">gerrit.installCommitMsgHookCommand</a>
+ Optional command to install the commit-msg hook. Typically of the form:
+ `fetch-cmd some://url/to/commit-msg .git/hooks/commit-msg ; chmod +x .git/hooks/commit-msg`
+ By default unset; falls back to using scp from the canonical SSH host,
+ or curl from the canonical HTTP URL for the server. Only necessary
+ if a proxy or other server/network configuration prevents clients
+ from fetching from the default location.
+
+<a id="gerrit.installCommitExtraCommand">gerrit.installCommitExtraCommand</a>
+ Optional command to complete the commit-msg hook. For example:
+ `git submodule update --init --recursive && git review -s`
+ would initialize the submodules and setup git review.
\ No newline at end of file