Extract minimum length of a SHA-1 as a public constant
Change-Id: I3cb2c3e7256189e4b94e97343f8f38dae6723d5d
This commit is contained in:
@@ -18,6 +18,7 @@ import com.google.gwtorm.client.Column;
|
|||||||
|
|
||||||
/** A revision identifier for a file or a change. */
|
/** A revision identifier for a file or a change. */
|
||||||
public final class RevId {
|
public final class RevId {
|
||||||
|
public static final int ABBREV_LEN = 7;
|
||||||
public static final int LEN = 40;
|
public static final int LEN = 40;
|
||||||
|
|
||||||
@Column(id = 1, length = LEN)
|
@Column(id = 1, length = LEN)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.google.gerrit.common.PageLinks;
|
|||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
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.GerritPersonIdent;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.WatchConfig;
|
import com.google.gerrit.server.account.WatchConfig;
|
||||||
@@ -202,7 +203,6 @@ public class CommitValidators {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class ChangeIdValidator implements CommitValidationListener {
|
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 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 " + FooterConstants.CHANGE_ID.getName() + " in commit message footer";
|
||||||
@@ -245,7 +245,7 @@ public class CommitValidators {
|
|||||||
RevCommit commit = receiveEvent.commit;
|
RevCommit commit = receiveEvent.commit;
|
||||||
List<CommitValidationMessage> messages = new ArrayList<>();
|
List<CommitValidationMessage> messages = new ArrayList<>();
|
||||||
List<String> idList = commit.getFooterLines(FooterConstants.CHANGE_ID);
|
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 (idList.isEmpty()) {
|
||||||
if (projectControl.getProjectState().isRequireChangeID()) {
|
if (projectControl.getProjectState().isRequireChangeID()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user