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