Merge branch 'stable-2.15'
* stable-2.15: List{Branches,Tags}: "can_delete" should not be set when false Change-Id: I4b62fbb7063358b0fc2db9ab5cd6bd59b5fe81cf
This commit is contained in:
@@ -1364,7 +1364,6 @@ Limit the number of branches to be included in the results.
|
||||
{
|
||||
"ref": "HEAD",
|
||||
"revision": "master",
|
||||
"can_delete": false
|
||||
}
|
||||
]
|
||||
----
|
||||
@@ -1388,7 +1387,6 @@ Skip the given number of branches from the beginning of the list.
|
||||
{
|
||||
"ref": "HEAD",
|
||||
"revision": "master",
|
||||
"can_delete": false
|
||||
}
|
||||
]
|
||||
----
|
||||
@@ -2722,7 +2720,7 @@ The `BranchInfo` entity contains information about a branch.
|
||||
|Field Name ||Description
|
||||
|`ref` ||The ref of the branch.
|
||||
|`revision` ||The revision to which the branch points.
|
||||
|`can_delete`|`false` if not set|
|
||||
|`can_delete`|not set if `false`|
|
||||
Whether the calling user can delete this branch.
|
||||
|`web_links` |optional|
|
||||
Links to the branch in external sites as a list of
|
||||
@@ -3281,7 +3279,7 @@ tag points.
|
||||
the signature.
|
||||
|`tagger`|Only set for annotated tags, if present in the tag.|The tagger as a
|
||||
link:rest-api-changes.html#git-person-info[GitPersonInfo] entity.
|
||||
|`can_delete`|`false` if not set|
|
||||
|`can_delete`|not set if `false`|
|
||||
Whether the calling user can delete this tag.
|
||||
|`web_links` |optional|
|
||||
Links to the tag in external sites as a list of
|
||||
|
@@ -24,7 +24,7 @@ public class TagInfo extends RefInfo {
|
||||
public GitPerson tagger;
|
||||
public List<WebLinkInfo> webLinks;
|
||||
|
||||
public TagInfo(String ref, String revision, boolean canDelete, List<WebLinkInfo> webLinks) {
|
||||
public TagInfo(String ref, String revision, Boolean canDelete, List<WebLinkInfo> webLinks) {
|
||||
this.ref = ref;
|
||||
this.revision = revision;
|
||||
this.canDelete = canDelete;
|
||||
@@ -37,7 +37,7 @@ public class TagInfo extends RefInfo {
|
||||
String object,
|
||||
String message,
|
||||
GitPerson tagger,
|
||||
boolean canDelete,
|
||||
Boolean canDelete,
|
||||
List<WebLinkInfo> webLinks) {
|
||||
this(ref, revision, canDelete, webLinks);
|
||||
this.object = object;
|
||||
|
@@ -190,7 +190,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
WebLinks links)
|
||||
throws MissingObjectException, IOException {
|
||||
RevObject object = rw.parseAny(ref.getObjectId());
|
||||
boolean canDelete = perm.testOrFalse(RefPermission.DELETE);
|
||||
Boolean canDelete = perm.testOrFalse(RefPermission.DELETE) ? true : null;
|
||||
List<WebLinkInfo> webLinks = links.getTagLinks(projectName.get(), ref.getName());
|
||||
if (object instanceof RevTag) {
|
||||
// Annotated or signed tag
|
||||
|
@@ -139,6 +139,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void assertDeleteSucceeds() throws Exception {
|
||||
assertThat(branch().get().canDelete).isTrue();
|
||||
String branchRev = branch().get().revision;
|
||||
branch().delete();
|
||||
eventRecorder.assertRefUpdatedEvents(
|
||||
@@ -148,6 +149,7 @@ public class DeleteBranchIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void assertDeleteForbidden() throws Exception {
|
||||
assertThat(branch().get().canDelete).isNull();
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("delete not permitted");
|
||||
branch().delete();
|
||||
|
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
@@ -22,6 +23,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.projects.TagApi;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
@@ -111,7 +113,9 @@ public class DeleteTagIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void assertDeleteSucceeds() throws Exception {
|
||||
String tagRev = tag().get().revision;
|
||||
TagInfo tagInfo = tag().get();
|
||||
assertThat(tagInfo.canDelete).isTrue();
|
||||
String tagRev = tagInfo.revision;
|
||||
tag().delete();
|
||||
eventRecorder.assertRefUpdatedEvents(project.get(), TAG, null, tagRev, tagRev, null);
|
||||
exception.expect(ResourceNotFoundException.class);
|
||||
@@ -119,6 +123,7 @@ public class DeleteTagIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private void assertDeleteForbidden() throws Exception {
|
||||
assertThat(tag().get().canDelete).isNull();
|
||||
exception.expect(AuthException.class);
|
||||
exception.expectMessage("delete not permitted");
|
||||
tag().delete();
|
||||
|
@@ -186,7 +186,7 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
|
||||
setApiUser(user);
|
||||
result = tag(input.ref).get();
|
||||
assertThat(result.canDelete).isFalse();
|
||||
assertThat(result.canDelete).isNull();
|
||||
|
||||
eventRecorder.assertRefUpdatedEvents(project.get(), result.ref, null, result.revision);
|
||||
}
|
||||
|
Reference in New Issue
Block a user