Add a new permission to permit rebasing changes in the web UI

So far only the change owner and submitters are permitted to rebase a
change in the web UI by pushing the 'Rebase Change' button. This change
introduces a new access right that can be assigned to other users to
permit them to do the rebase in the web UI as well.

Change-Id: I21e9981bd685f1d69e792abbd7eeaf1a60d039b8
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2012-05-09 21:09:55 +02:00
committed by Gustaf Lundh
parent cb0ca18ab1
commit fd330fc69c
5 changed files with 27 additions and 1 deletions

View File

@@ -703,6 +703,21 @@ be suitable in a corporate deployment if the HTTP access control
is already restricted to the correct set of users.
[[category_rebase]]
Rebase
~~~~~~
This category permits users to rebase changes via the web UI by pushing
the `Rebase Change` button.
The change owner and submitters can always rebase changes in the web UI
(even without having the `Rebase` access right assigned).
Users without this access right who are able to upload new patch sets
can still do the rebase locally and upload the rebased commit as a new
patch set.
[[category_submit]]
Submit
~~~~~~

View File

@@ -30,6 +30,7 @@ public class Permission implements Comparable<Permission> {
public static final String PUSH_MERGE = "pushMerge";
public static final String PUSH_TAG = "pushTag";
public static final String READ = "read";
public static final String REBASE = "rebase";
public static final String SUBMIT = "submit";
private static final List<String> NAMES_LC;
@@ -47,6 +48,7 @@ public class Permission implements Comparable<Permission> {
NAMES_LC.add(PUSH_MERGE.toLowerCase());
NAMES_LC.add(PUSH_TAG.toLowerCase());
NAMES_LC.add(LABEL.toLowerCase());
NAMES_LC.add(REBASE.toLowerCase());
NAMES_LC.add(SUBMIT.toLowerCase());
labelIndex = NAMES_LC.indexOf(Permission.LABEL);

View File

@@ -102,6 +102,7 @@ permissionNames = \
pushMerge, \
pushTag, \
read, \
rebase, \
submit
create = Create Reference
forgeAuthor = Forge Author Identity
@@ -112,6 +113,7 @@ push = Push
pushMerge = Push Merge Commit
pushTag = Push Annotated Tag
read = Read
rebase = Rebase
submit = Submit
refErrorEmpty = Reference must be supplied

View File

@@ -204,7 +204,8 @@ public class ChangeControl {
/** Can this user rebase this change? */
public boolean canRebase() {
return isOwner() || getRefControl().canSubmit();
return isOwner() || getRefControl().canSubmit()
|| getRefControl().canRebase();
}
/** Can this user restore this change? */

View File

@@ -125,6 +125,12 @@ public class RefControl {
&& canWrite();
}
/** @return true if this user can rebase changes on this ref */
public boolean canRebase() {
return canPerform(Permission.REBASE)
&& canWrite();
}
/** @return true if this user can submit patch sets to this ref */
public boolean canSubmit() {
if (GitRepositoryManager.REF_CONFIG.equals(refName)) {