Merge changes I9254b309,Id74f483a

* changes:
  Shorten hook download command
  Inline "Change-Id" string into error messages
This commit is contained in:
Edwin Kempin
2018-07-30 13:37:07 +00:00
committed by Gerrit Code Review

View File

@@ -238,25 +238,17 @@ public class CommitValidators {
public static class ChangeIdValidator implements CommitValidationListener { public static class ChangeIdValidator implements CommitValidationListener {
private static final String CHANGE_ID_PREFIX = FooterConstants.CHANGE_ID.getName() + ":"; private static final String CHANGE_ID_PREFIX = FooterConstants.CHANGE_ID.getName() + ":";
private static final String MISSING_CHANGE_ID_MSG = private static final String MISSING_CHANGE_ID_MSG =
"[%s] missing " + FooterConstants.CHANGE_ID.getName() + " in commit message footer"; "[%s] missing Change-Id in commit message footer";
private static final String MISSING_SUBJECT_MSG = private static final String MISSING_SUBJECT_MSG =
"[%s] missing subject; " "[%s] missing subject; Change-Id must be in commit message footer";
+ FooterConstants.CHANGE_ID.getName()
+ " must be in commit message footer";
private static final String MULTIPLE_CHANGE_ID_MSG = private static final String MULTIPLE_CHANGE_ID_MSG =
"[%s] multiple " + FooterConstants.CHANGE_ID.getName() + " lines in commit message footer"; "[%s] multiple Change-Id lines in commit message footer";
private static final String INVALID_CHANGE_ID_MSG = private static final String INVALID_CHANGE_ID_MSG =
"[%s] invalid " "[%s] invalid Change-Id line format in commit message footer";
+ FooterConstants.CHANGE_ID.getName()
+ " line format in commit message footer";
@VisibleForTesting @VisibleForTesting
public static final String CHANGE_ID_MISMATCH_MSG = public static final String CHANGE_ID_MISMATCH_MSG =
"[%s] " "[%s] Change-Id in commit message footer does not match Change-Id of target change";
+ FooterConstants.CHANGE_ID.getName()
+ " in commit message footer does not match"
+ FooterConstants.CHANGE_ID.getName()
+ " of target change";
private static final Pattern CHANGE_ID = Pattern.compile(CHANGE_ID_PATTERN); private static final Pattern CHANGE_ID = Pattern.compile(CHANGE_ID_PATTERN);
@@ -367,10 +359,9 @@ public class CommitValidators {
// If there are no SSH keys, the commit-msg hook must be installed via // If there are no SSH keys, the commit-msg hook must be installed via
// HTTP(S) // HTTP(S)
if (hostKeys.isEmpty()) { if (hostKeys.isEmpty()) {
String p = "${gitdir}/hooks/commit-msg";
return String.format( return String.format(
" gitdir=$(git rev-parse --git-dir); curl -o %s %stools/hooks/commit-msg ; chmod +x %s", " f=\"$(git rev-parse --git-dir)/hooks/commit-msg\"; curl -o \"$f\" %stools/hooks/commit-msg ; chmod +x \"$f\"",
p, canonicalWebUrl, p); canonicalWebUrl);
} }
// SSH keys exist, so the hook can be installed with scp. // SSH keys exist, so the hook can be installed with scp.