My favorites
▼
|
Sign in
gerrit
Gerrit Code Review
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
New issue
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
1258
attachment: 0001-check-commit-before-replace-change.patch
(1.9 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From 9f2959c8ef3c74b0397078169ba3e4bac90168e1 Mon Sep 17 00:00:00 2001
From: Chengwei Yang <chengwei.yang@intel.com>
Date: Thu, 9 Feb 2012 13:54:45 +0800
Subject: [PATCH] check commit before replace change
$ git push ... HEAD:refs/changes/ID
We assuming that HEAD has been merged sometime before and ID is open and
who did the command with no privileges to submit merge in Gerrit.
Currently, the above command will cause Gerrit to close change ID and
get it merged and notice all the listeners. So most of listeners may be
confused why it got merged since the pusher even has no privileges to
submit.
This patch check the commit whether it has been merged already, if so,
just reject it and notice the pusher.
---
.../google/gerrit/server/git/ReceiveCommits.java | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
index 8450dc5..983ec3f 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/ReceiveCommits.java
@@ -1090,6 +1090,15 @@ public class ReceiveCommits implements PreReceiveHook, PostReceiveHook {
return null;
}
+ // If the new commit has already been merged, then reject it
+ for (final PatchSet ps : db.patchSets().byRevision(toRevId(c))) {
+ Change tmpChange = db.changes().get(ps.getId().getParentKey());
+ if (tmpChange.getStatus() == Change.Status.MERGED) {
+ reject(request.cmd, "the commit has already been merged");
+ return null;
+ }
+ }
+
final PatchSet.Id priorPatchSet = change.currentPatchSetId();
for (final PatchSet ps : db.patchSets().byChange(request.ontoChange)) {
if (ps.getRevision() == null) {
--
1.7.2.5
Powered by
Google Project Hosting