Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Fix changes not found
  Extract minimum length of a SHA-1 as a public constant

Change-Id: If1ab1cf7807cc791499e1210a2426831a7b5352a
This commit is contained in:
Hector Oswaldo Caballero
2017-10-18 22:56:58 -04:00
4 changed files with 5 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ notifications when changes are made.
Changes can be specified in the
link:rest-api-changes.html#change-id[same format] supported by the REST
API, as well as with the commit SHA-1.
API, as well as with the commit SHA-1 (at least the 7 first characters).
== OPTIONS

View File

@@ -18,6 +18,7 @@ import com.google.gwtorm.client.Column;
/** A revision identifier for a file or a change. */
public final class RevId {
public static final int ABBREV_LEN = 7;
public static final int LEN = 40;
@Column(id = 1, length = LEN)

View File

@@ -111,7 +111,7 @@ public class ChangeFinder {
InternalChangeQuery query = queryProvider.get().noFields();
//Try commit hash
if (id.matches("^([0-9a-fA-F]{4," + RevId.LEN + "})$")) {
if (id.matches("^([0-9a-fA-F]{" + RevId.ABBREV_LEN + "," + RevId.LEN + "})$")) {
return asChangeNotes(query.byCommit(id));
}

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.client.RevId;
import com.google.gerrit.server.GerritPersonIdent;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.WatchConfig;
@@ -204,7 +205,6 @@ public class CommitValidators {
}
public static class ChangeIdValidator implements CommitValidationListener {
private static final int SHA1_LENGTH = 7;
private static final String CHANGE_ID_PREFIX = FooterConstants.CHANGE_ID.getName() + ":";
private static final String MISSING_CHANGE_ID_MSG =
"[%s] missing " + FooterConstants.CHANGE_ID.getName() + " in commit message footer";
@@ -248,7 +248,7 @@ public class CommitValidators {
RevCommit commit = receiveEvent.commit;
List<CommitValidationMessage> messages = new ArrayList<>();
List<String> idList = commit.getFooterLines(FooterConstants.CHANGE_ID);
String sha1 = commit.abbreviate(SHA1_LENGTH).name();
String sha1 = commit.abbreviate(RevId.ABBREV_LEN).name();
if (idList.isEmpty()) {
if (projectState.isRequireChangeID()) {