diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java index e067f0624f..448ce868fa 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/ChangeDetail.java @@ -29,6 +29,7 @@ public class ChangeDetail { protected boolean canAbandon; protected boolean canEditCommitMessage; protected boolean canCherryPick; + protected boolean canEditHashtags; protected boolean canPublish; protected boolean canRebase; protected boolean canRestore; @@ -93,6 +94,14 @@ public class ChangeDetail { canCherryPick = a; } + public boolean getCanEditHashtags() { + return canEditHashtags; + } + + public void setCanEditHashtags(final boolean a) { + canEditHashtags = a; + } + public boolean canPublish() { return canPublish; } diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/Permission.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/Permission.java index 2379b4ac9e..2d9965e688 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/Permission.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/Permission.java @@ -24,6 +24,7 @@ public class Permission implements Comparable { public static final String ABANDON = "abandon"; public static final String CREATE = "create"; public static final String DELETE_DRAFTS = "deleteDrafts"; + public static final String EDIT_HASHTAGS = "editHashtags"; public static final String EDIT_TOPIC_NAME = "editTopicName"; public static final String FORGE_AUTHOR = "forgeAuthor"; public static final String FORGE_COMMITTER = "forgeCommitter"; @@ -68,6 +69,7 @@ public class Permission implements Comparable { NAMES_LC.add(SUBMIT_AS.toLowerCase()); NAMES_LC.add(VIEW_DRAFTS.toLowerCase()); NAMES_LC.add(EDIT_TOPIC_NAME.toLowerCase()); + NAMES_LC.add(EDIT_HASHTAGS.toLowerCase()); NAMES_LC.add(DELETE_DRAFTS.toLowerCase()); NAMES_LC.add(PUBLISH_DRAFTS.toLowerCase()); diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/data/ReviewResult.java b/gerrit-common/src/main/java/com/google/gerrit/common/data/ReviewResult.java index f82f434479..76785d8f65 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/data/ReviewResult.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/data/ReviewResult.java @@ -85,7 +85,10 @@ public class ReviewResult { DEST_BRANCH_NOT_FOUND, /** Not permitted to edit the topic name */ - EDIT_TOPIC_NAME_NOT_PERMITTED + EDIT_TOPIC_NAME_NOT_PERMITTED, + + /** Not permitted to edit the hashtags */ + EDIT_HASHTAGS_NOT_PERMITTED } protected Type type; diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties index df793807d3..1bb0386e32 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AdminConstants.properties @@ -109,6 +109,7 @@ permissionNames = \ abandon, \ create, \ deleteDrafts, \ + editHashtags, \ editTopicName, \ forgeAuthor, \ forgeCommitter, \ @@ -129,6 +130,7 @@ permissionNames = \ abandon = Abandon create = Create Reference deleteDrafts = Delete Drafts +editHashtags = Edit Hashtags editTopicName = Edit Topic Name forgeAuthor = Forge Author Identity forgeCommitter = Forge Committer Identity diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java index 37aafe0678..e93f69c82c 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ChangeControl.java @@ -413,6 +413,16 @@ public class ChangeControl { } } + /** Can this user edit the hashtag name? */ + public boolean canEditHashtags() { + return isOwner() // owner (aka creator) of the change can edit hashtags + || getRefControl().isOwner() // branch owner can edit hashtags + || getProjectControl().isOwner() // project owner can edit hashtags + || getCurrentUser().getCapabilities().canAdministrateServer() // site administers are god + || getRefControl().canEditHashtags(); // user can edit hashtag on a specific ref + } + + public List getSubmitRecords(ReviewDb db, PatchSet patchSet) { return canSubmit(db, patchSet, null, false, true, false); } diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java index 9848faa251..d3a8b692b6 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/RefControl.java @@ -424,6 +424,11 @@ public class RefControl { return canPerform(Permission.EDIT_TOPIC_NAME); } + /** @return true if this user can edit hashtag names. */ + public boolean canEditHashtags() { + return canPerform(Permission.EDIT_HASHTAGS); + } + /** @return true if this user can force edit topic names. */ public boolean canForceEditTopicName() { return canForcePerform(Permission.EDIT_TOPIC_NAME);