Don't allow users to amend commits made by Gerrit Code Review
All too often I'm seeing users update their project, make a new change, then amend the current HEAD commit to record the change, rather than creating a new commit. By amending the HEAD commit they are often amending a merge commit created by Gerrit Code Review, and then they expect this to merge into the repository somehow when they submit the change. This is completely incorrect usage and apparently some users cannot be trusted to not do it. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -1092,9 +1092,23 @@ class Receive extends AbstractGitCommand {
|
||||
}
|
||||
|
||||
private boolean validCommitter(final ReceiveCommand cmd, final RevCommit c) {
|
||||
final PersonIdent committer = c.getCommitterIdent();
|
||||
final PersonIdent author = c.getAuthorIdent();
|
||||
|
||||
// Don't allow the user to amend a merge created by Gerrit Code Review.
|
||||
// This seems to happen all too often, due to users not paying any
|
||||
// attention to what they are doing.
|
||||
//
|
||||
final PersonIdent serverIdent = server.newGerritPersonIdent();
|
||||
if (c.getParentCount() > 1
|
||||
&& author.getName().equals(serverIdent.getName())
|
||||
&& author.getEmailAddress().equals(serverIdent.getEmailAddress())) {
|
||||
reject(cmd, "do not amend merges not made by you");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Require that committer matches the uploader.
|
||||
//
|
||||
final PersonIdent committer = c.getCommitterIdent();
|
||||
if (!myEmails.contains(committer.getEmailAddress())) {
|
||||
reject(cmd, "you are not committer " + committer.getEmailAddress());
|
||||
return false;
|
||||
@@ -1104,7 +1118,6 @@ class Receive extends AbstractGitCommand {
|
||||
// If the project wants Signed-off-by / Acked-by lines, verify we
|
||||
// have them for the blamable parties involved on this change.
|
||||
//
|
||||
final PersonIdent author = c.getAuthorIdent();
|
||||
boolean sboAuthor = false, sboCommitter = false, sboMe = false;
|
||||
for (final FooterLine footer : c.getFooterLines()) {
|
||||
if (footer.matches(FooterKey.SIGNED_OFF_BY)) {
|
||||
|
Reference in New Issue
Block a user