Merge branch 'stable-2.11'
* stable-2.11: PatchListLoader: Synchronize MyersDiff and HistogramDiff invocations Update singleusergroup to latest revision ListTags: Fix ref in TagInfo for signed/annotated tags Fix review labels with AnyWithBlock function Fix NullPointerException in ls-project command with --has-acl-for option Change-Id: Id758eada94c051b4137e6ffaefba1ef9093d30cc
This commit is contained in:
commit
1acb946b48
@ -17,6 +17,7 @@ package com.google.gerrit.acceptance.rest.project;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
@ -26,6 +27,11 @@ import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.eclipse.jgit.api.PushCommand;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.transport.PushResult;
|
||||
import org.eclipse.jgit.transport.RefSpec;
|
||||
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
@ -84,15 +90,29 @@ public class TagsIT extends AbstractDaemonTest {
|
||||
PushOneCommit.Result r2 = push2.to("refs/for/master%submit");
|
||||
r2.assertOkStatus();
|
||||
|
||||
String tag3Ref = Constants.R_TAGS + "vLatest";
|
||||
PushCommand pushCmd = testRepo.git().push();
|
||||
pushCmd.setRefSpecs(new RefSpec(tag2.name + ":" + tag3Ref));
|
||||
Iterable<PushResult> r = pushCmd.call();
|
||||
assertThat(Iterables.getOnlyElement(r).getRemoteUpdate(tag3Ref).getStatus())
|
||||
.isEqualTo(Status.OK);
|
||||
|
||||
List<TagInfo> result = getTags().get();
|
||||
assertThat(result).hasSize(2);
|
||||
assertThat(result).hasSize(3);
|
||||
|
||||
TagInfo t = result.get(0);
|
||||
assertThat(t.ref).isEqualTo("refs/tags/" + tag1.name);
|
||||
assertThat(t.ref).isEqualTo(Constants.R_TAGS + tag1.name);
|
||||
assertThat(t.revision).isEqualTo(r1.getCommitId().getName());
|
||||
|
||||
t = result.get(1);
|
||||
assertThat(t.ref).isEqualTo("refs/tags/" + tag2.name);
|
||||
assertThat(t.ref).isEqualTo(Constants.R_TAGS + tag2.name);
|
||||
assertThat(t.object).isEqualTo(r2.getCommitId().getName());
|
||||
assertThat(t.message).isEqualTo(tag2.message);
|
||||
assertThat(t.tagger.name).isEqualTo(tag2.tagger.getName());
|
||||
assertThat(t.tagger.email).isEqualTo(tag2.tagger.getEmailAddress());
|
||||
|
||||
t = result.get(2);
|
||||
assertThat(t.ref).isEqualTo(tag3Ref);
|
||||
assertThat(t.object).isEqualTo(r2.getCommitId().getName());
|
||||
assertThat(t.message).isEqualTo(tag2.message);
|
||||
assertThat(t.tagger.name).isEqualTo(tag2.tagger.getName());
|
||||
|
@ -24,6 +24,7 @@ import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.LabelInfo;
|
||||
@ -43,6 +44,10 @@ public class CustomLabelIT extends AbstractDaemonTest {
|
||||
value(0, "No score"),
|
||||
value(-1, "Negative"));
|
||||
|
||||
private final LabelType P = category("CustomLabel2",
|
||||
value(1, "Positive"),
|
||||
value(0, "No score"));
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
|
||||
@ -50,6 +55,8 @@ public class CustomLabelIT extends AbstractDaemonTest {
|
||||
SystemGroupBackend.getGroup(ANONYMOUS_USERS).getUUID();
|
||||
Util.allow(cfg, Permission.forLabel(label.getName()), -1, 1, anonymousUsers,
|
||||
"refs/heads/*");
|
||||
Util.allow(cfg, Permission.forLabel(P.getName()), 0, 1, anonymousUsers,
|
||||
"refs/heads/*");
|
||||
saveProjectConfig(project, cfg);
|
||||
}
|
||||
|
||||
@ -106,6 +113,26 @@ public class CustomLabelIT extends AbstractDaemonTest {
|
||||
assertThat(q.blocking).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customLabelAnyWithBlock_Addreviewer_ZeroVote() throws Exception {
|
||||
P.setFunctionName("AnyWithBlock");
|
||||
saveLabelConfig();
|
||||
PushOneCommit.Result r = createChange();
|
||||
AddReviewerInput in = new AddReviewerInput();
|
||||
in.reviewer = user.email;
|
||||
gApi.changes()
|
||||
.id(r.getChangeId())
|
||||
.addReviewer(in);
|
||||
|
||||
revision(r).review(new ReviewInput().label(P.getName(), 0));
|
||||
ChangeInfo c = get(r.getChangeId());
|
||||
LabelInfo q = c.labels.get(P.getName());
|
||||
assertThat(q.all).hasSize(2);
|
||||
assertThat(q.disliked).isNull();
|
||||
assertThat(q.rejected).isNull();
|
||||
assertThat(q.blocking).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customLabelMaxWithBlock_NegativeVoteBlock() throws Exception {
|
||||
saveLabelConfig();
|
||||
@ -122,6 +149,7 @@ public class CustomLabelIT extends AbstractDaemonTest {
|
||||
private void saveLabelConfig() throws Exception {
|
||||
ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
|
||||
cfg.getLabelSections().put(label.getName(), label);
|
||||
cfg.getLabelSections().put(P.getName(), P);
|
||||
saveProjectConfig(project, cfg);
|
||||
}
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
private final PatchListKey key;
|
||||
private final Project.NameKey project;
|
||||
private final long timeoutMillis;
|
||||
private final Object lock;
|
||||
|
||||
@AssistedInject
|
||||
PatchListLoader(GitRepositoryManager mgr,
|
||||
@ -107,6 +108,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
diffExecutor = de;
|
||||
key = k;
|
||||
project = p;
|
||||
lock = new Object();
|
||||
timeoutMillis =
|
||||
ConfigUtil.getTimeUnit(cfg, "cache", PatchListCacheImpl.FILE_NAME,
|
||||
"timeout", TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS),
|
||||
@ -210,7 +212,9 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
Future<FileHeader> result = diffExecutor.submit(new Callable<FileHeader>() {
|
||||
@Override
|
||||
public FileHeader call() throws IOException {
|
||||
return diffFormatter.toFileHeader(diffEntry);
|
||||
synchronized (lock) {
|
||||
return diffFormatter.toFileHeader(diffEntry);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -224,7 +228,9 @@ public class PatchListLoader implements Callable<PatchList> {
|
||||
+ " comparing " + diffEntry.getOldId().name()
|
||||
+ ".." + diffEntry.getNewId().name());
|
||||
result.cancel(true);
|
||||
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
|
||||
synchronized (lock) {
|
||||
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
|
||||
}
|
||||
} catch (ExecutionException e) {
|
||||
// If there was an error computing the result, carry it
|
||||
// up to the caller so the cache knows this key is invalid.
|
||||
|
@ -37,9 +37,9 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.OutputFormat;
|
||||
import com.google.gerrit.server.StringUtil;
|
||||
import com.google.gerrit.server.WebLinks;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.group.GroupsCollection;
|
||||
import com.google.gerrit.server.util.RegexListSearcher;
|
||||
import com.google.gerrit.server.util.TreeFormatter;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
@ -109,7 +109,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
|
||||
private final CurrentUser currentUser;
|
||||
private final ProjectCache projectCache;
|
||||
private final GroupCache groupCache;
|
||||
private final GroupsCollection groupsCollection;
|
||||
private final GroupControl.Factory groupControlFactory;
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final ProjectNode.Factory projectNodeFactory;
|
||||
@ -191,13 +191,16 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
private AccountGroup.UUID groupUuid;
|
||||
|
||||
@Inject
|
||||
protected ListProjects(CurrentUser currentUser, ProjectCache projectCache,
|
||||
GroupCache groupCache, GroupControl.Factory groupControlFactory,
|
||||
GitRepositoryManager repoManager, ProjectNode.Factory projectNodeFactory,
|
||||
protected ListProjects(CurrentUser currentUser,
|
||||
ProjectCache projectCache,
|
||||
GroupsCollection groupsCollection,
|
||||
GroupControl.Factory groupControlFactory,
|
||||
GitRepositoryManager repoManager,
|
||||
ProjectNode.Factory projectNodeFactory,
|
||||
WebLinks webLinks) {
|
||||
this.currentUser = currentUser;
|
||||
this.projectCache = projectCache;
|
||||
this.groupCache = groupCache;
|
||||
this.groupsCollection = groupsCollection;
|
||||
this.groupControlFactory = groupControlFactory;
|
||||
this.repoManager = repoManager;
|
||||
this.projectNodeFactory = projectNodeFactory;
|
||||
@ -280,7 +283,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
break;
|
||||
}
|
||||
if (!pctl.getLocalGroups().contains(
|
||||
GroupReference.forGroup(groupCache.get(groupUuid)))) {
|
||||
GroupReference.forGroup(groupsCollection.parseId(groupUuid.get())))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class ListTags implements RestReadView<ProjectResource> {
|
||||
RevTag tag = (RevTag)object;
|
||||
// Annotated or signed tag
|
||||
return new TagInfo(
|
||||
Constants.R_TAGS + tag.getTagName(),
|
||||
ref.getName(),
|
||||
tag.getName(),
|
||||
tag.getObject().getName(),
|
||||
tag.getFullMessage().trim(),
|
||||
|
@ -283,6 +283,7 @@ max_with_block(Label, Min, Max, need(Max)) :-
|
||||
%% - The maximum is never used.
|
||||
%%
|
||||
any_with_block(Label, Min, reject(Who)) :-
|
||||
Min < 0,
|
||||
check_label_range_permission(Label, Min, ok(Who)),
|
||||
!
|
||||
.
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 6fb010107a7dfdd6baff2b54e65fb74c933d6654
|
||||
Subproject commit f6df7121d2704e73c2a315a660e5cc4e12ab1ab9
|
Loading…
Reference in New Issue
Block a user