Add ChangeApi.get() method
Change-Id: I9862a2475781a37c6b964d2a977b3d187d44cf09
This commit is contained in:
@@ -16,6 +16,7 @@ package com.google.gerrit.acceptance.api.change;
|
||||
|
||||
import static com.google.gerrit.acceptance.GitUtil.cloneProject;
|
||||
import static com.google.gerrit.acceptance.GitUtil.createProject;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.AcceptanceTestRequestScope;
|
||||
@@ -25,6 +26,9 @@ import com.google.gerrit.acceptance.TestAccount;
|
||||
import com.google.gerrit.extensions.api.GerritApi;
|
||||
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.ChangeStatus;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -41,6 +45,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class ChangeIT extends AbstractDaemonTest {
|
||||
|
||||
@@ -81,6 +86,25 @@ public class ChangeIT extends AbstractDaemonTest {
|
||||
db.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void get() throws GitAPIException,
|
||||
IOException, RestApiException {
|
||||
PushOneCommit.Result r = createChange();
|
||||
String triplet = "p~master~" + r.getChangeId();
|
||||
ChangeInfo c =
|
||||
gApi.changes()
|
||||
.id(triplet)
|
||||
.get(EnumSet.noneOf(ListChangesOption.class));
|
||||
assertEquals(triplet, c.id);
|
||||
assertEquals("p", c.project);
|
||||
assertEquals("master", c.branch);
|
||||
assertEquals(ChangeStatus.NEW, c.status);
|
||||
assertEquals("test commit", c.subject);
|
||||
assertEquals(true, c.mergeable);
|
||||
assertEquals(r.getChangeId(), c.changeId);
|
||||
assertEquals(c.created, c.updated);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void abandon() throws GitAPIException,
|
||||
IOException, RestApiException {
|
||||
|
||||
@@ -14,8 +14,12 @@
|
||||
|
||||
package com.google.gerrit.extensions.api.changes;
|
||||
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
public interface ChangeApi {
|
||||
String id();
|
||||
|
||||
@@ -34,4 +38,6 @@ public interface ChangeApi {
|
||||
|
||||
void addReviewer(AddReviewerInput in) throws RestApiException;
|
||||
void addReviewer(String in) throws RestApiException;
|
||||
|
||||
ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
public class AccountInfo {
|
||||
public Integer _accountId;
|
||||
public String name;
|
||||
public String email;
|
||||
public String username;
|
||||
}
|
||||
@@ -12,15 +12,15 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.actions;
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import com.google.gerrit.extensions.webui.UiAction;
|
||||
|
||||
public class ActionInfo {
|
||||
String method;
|
||||
String label;
|
||||
String title;
|
||||
Boolean enabled;
|
||||
public String method;
|
||||
public String label;
|
||||
public String title;
|
||||
public Boolean enabled;
|
||||
|
||||
public ActionInfo(UiAction.Description d) {
|
||||
method = d.getMethod();
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class ApprovalInfo extends AccountInfo {
|
||||
public Integer value;
|
||||
public Timestamp date;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChangeInfo {
|
||||
public String id;
|
||||
public String project;
|
||||
public String branch;
|
||||
public String topic;
|
||||
public String changeId;
|
||||
public String subject;
|
||||
public ChangeStatus status;
|
||||
public Timestamp created;
|
||||
public Timestamp updated;
|
||||
public Boolean starred;
|
||||
public Boolean reviewed;
|
||||
public Boolean mergeable;
|
||||
public Integer insertions;
|
||||
public Integer deletions;
|
||||
public AccountInfo owner;
|
||||
public String currentRevision;
|
||||
public Map<String, ActionInfo> actions;
|
||||
public Map<String, LabelInfo> labels;
|
||||
public Collection<ChangeMessageInfo> messages;
|
||||
public Map<String, RevisionInfo> revisions;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class ChangeMessageInfo {
|
||||
public String id;
|
||||
public AccountInfo author;
|
||||
public Timestamp date;
|
||||
public String message;
|
||||
public Integer _revisionNumber;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommitInfo {
|
||||
public String commit;
|
||||
public List<CommitInfo> parents;
|
||||
public GitPerson author;
|
||||
public GitPerson committer;
|
||||
public String subject;
|
||||
public String message;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class FetchInfo {
|
||||
public String url;
|
||||
public String ref;
|
||||
public Map<String, String> commands;
|
||||
|
||||
public FetchInfo(String url, String ref) {
|
||||
this.url = url;
|
||||
this.ref = ref;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
public class FileInfo {
|
||||
public Character status;
|
||||
public Boolean binary;
|
||||
public String oldPath;
|
||||
public Integer linesInserted;
|
||||
public Integer linesDeleted;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class GitPerson {
|
||||
public String name;
|
||||
public String email;
|
||||
public Timestamp date;
|
||||
public int tz;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LabelInfo {
|
||||
public AccountInfo approved;
|
||||
public AccountInfo rejected;
|
||||
public AccountInfo recommended;
|
||||
public AccountInfo disliked;
|
||||
public List<ApprovalInfo> all;
|
||||
public Map<String, String> values;
|
||||
public Short value;
|
||||
public Boolean optional;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.extensions.common;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class RevisionInfo {
|
||||
public transient boolean isCurrent;
|
||||
public Boolean draft;
|
||||
public Boolean hasDraftComments;
|
||||
public int _number;
|
||||
public Map<String, FetchInfo> fetch;
|
||||
public CommitInfo commit;
|
||||
public Map<String, FileInfo> files;
|
||||
public Map<String, ActionInfo> actions;
|
||||
}
|
||||
@@ -22,9 +22,12 @@ import com.google.gerrit.extensions.api.changes.Changes;
|
||||
import com.google.gerrit.extensions.api.changes.RestoreInput;
|
||||
import com.google.gerrit.extensions.api.changes.RevertInput;
|
||||
import com.google.gerrit.extensions.api.changes.RevisionApi;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.change.Abandon;
|
||||
import com.google.gerrit.server.change.ChangeJson;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.change.PostReviewers;
|
||||
import com.google.gerrit.server.change.Restore;
|
||||
@@ -36,6 +39,7 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
class ChangeApiImpl implements ChangeApi {
|
||||
interface Factory {
|
||||
@@ -50,6 +54,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
private final Provider<Revert> revert;
|
||||
private final Provider<Restore> restore;
|
||||
private final Provider<PostReviewers> postReviewers;
|
||||
private final ChangeJson changeJson;
|
||||
|
||||
@Inject
|
||||
ChangeApiImpl(Changes changeApi,
|
||||
@@ -59,6 +64,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
Provider<Revert> revert,
|
||||
Provider<Restore> restore,
|
||||
Provider<PostReviewers> postReviewers,
|
||||
ChangeJson changeJson,
|
||||
@Assisted ChangeResource change) {
|
||||
this.changeApi = changeApi;
|
||||
this.revert = revert;
|
||||
@@ -67,6 +73,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
this.abandon = abandon;
|
||||
this.restore = restore;
|
||||
this.postReviewers = postReviewers;
|
||||
this.changeJson = changeJson;
|
||||
this.change = change;
|
||||
}
|
||||
|
||||
@@ -152,4 +159,15 @@ class ChangeApiImpl implements ChangeApi {
|
||||
throw new RestApiException("Cannot add change reviewer", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangeInfo get(EnumSet<ListChangesOption> s)
|
||||
throws RestApiException {
|
||||
try {
|
||||
return new ChangeInfoMapper(s).map(
|
||||
changeJson.addOptions(s).format(change));
|
||||
} catch (OrmException e) {
|
||||
throw new RestApiException("Cannot retrieve change", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
// Copyright (C) 2014 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.api.changes;
|
||||
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.ALL_REVISIONS;
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.CURRENT_ACTIONS;
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.CURRENT_REVISION;
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.DETAILED_LABELS;
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.LABELS;
|
||||
import static com.google.gerrit.extensions.common.ListChangesOption.MESSAGES;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeStatus;
|
||||
import com.google.gerrit.extensions.common.LabelInfo;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
||||
import com.google.gerrit.server.change.ChangeJson;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
class ChangeInfoMapper {
|
||||
private final static ImmutableMap<Change.Status, ChangeStatus> MAP =
|
||||
Maps.immutableEnumMap(ImmutableMap.of(
|
||||
Status.DRAFT, ChangeStatus.DRAFT,
|
||||
Status.NEW, ChangeStatus.NEW,
|
||||
Status.SUBMITTED, ChangeStatus.SUBMITTED,
|
||||
Status.MERGED, ChangeStatus.MERGED,
|
||||
Status.ABANDONED, ChangeStatus.ABANDONED));
|
||||
|
||||
private final EnumSet<ListChangesOption> s;
|
||||
|
||||
ChangeInfoMapper(EnumSet<ListChangesOption> s) {
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
ChangeInfo map(ChangeJson.ChangeInfo i) {
|
||||
ChangeInfo o = new ChangeInfo();
|
||||
mapCommon(i, o);
|
||||
if (has(LABELS) || has(DETAILED_LABELS)) {
|
||||
mapLabels(i, o);
|
||||
}
|
||||
if (has(MESSAGES)) {
|
||||
mapMessages(i, o);
|
||||
}
|
||||
if (has(ALL_REVISIONS) || has(CURRENT_REVISION)) {
|
||||
o.revisions = i.revisions;
|
||||
}
|
||||
if (has(CURRENT_ACTIONS)) {
|
||||
o.actions = i.actions;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
private void mapCommon(ChangeJson.ChangeInfo i, ChangeInfo o) {
|
||||
o.id = i.id;
|
||||
o.project = i.project;
|
||||
o.branch = i.branch;
|
||||
o.topic = i.topic;
|
||||
o.changeId = i.changeId;
|
||||
o.subject = i.subject;
|
||||
o.status = MAP.get(i.status);
|
||||
o.created = i.created;
|
||||
o.updated = i.updated;
|
||||
o.starred = i.starred;
|
||||
o.reviewed = i.reviewed;
|
||||
o.mergeable = i.mergeable;
|
||||
o.insertions = i.insertions;
|
||||
o.deletions = i.deletions;
|
||||
o.owner = fromAcountInfo(i.owner);
|
||||
o.currentRevision = i.currentRevision;
|
||||
}
|
||||
|
||||
private void mapMessages(ChangeJson.ChangeInfo i, ChangeInfo o) {
|
||||
List<ChangeMessageInfo> r =
|
||||
Lists.newArrayListWithCapacity(i.messages.size());
|
||||
for (ChangeJson.ChangeMessageInfo m : i.messages) {
|
||||
ChangeMessageInfo cmi = new ChangeMessageInfo();
|
||||
cmi.id = m.id;
|
||||
cmi.author = fromAcountInfo(m.author);
|
||||
cmi.date = m.date;
|
||||
cmi.message = m.message;
|
||||
cmi._revisionNumber = m._revisionNumber;
|
||||
r.add(cmi);
|
||||
}
|
||||
o.messages = r;
|
||||
}
|
||||
|
||||
private void mapLabels(ChangeJson.ChangeInfo i, ChangeInfo o) {
|
||||
Map<String, LabelInfo> r = Maps.newLinkedHashMap();
|
||||
for (Map.Entry<String, ChangeJson.LabelInfo> e : i.labels.entrySet()) {
|
||||
ChangeJson.LabelInfo li = e.getValue();
|
||||
LabelInfo lo = new LabelInfo();
|
||||
lo.approved = fromAcountInfo(li.approved);
|
||||
lo.rejected = fromAcountInfo(li.rejected);
|
||||
lo.recommended = fromAcountInfo(li.recommended);
|
||||
lo.disliked = fromAcountInfo(li.disliked);
|
||||
lo.value = li.value;
|
||||
lo.optional = li.optional;
|
||||
lo.values = li.values;
|
||||
lo.all = Lists.newArrayListWithExpectedSize(li.all.size());
|
||||
for (ChangeJson.ApprovalInfo ai : li.all) {
|
||||
lo.all.add(fromApprovalInfo(ai));
|
||||
}
|
||||
r.put(e.getKey(), lo);
|
||||
}
|
||||
o.labels = r;
|
||||
}
|
||||
|
||||
private boolean has(ListChangesOption o) {
|
||||
return s.contains(o);
|
||||
}
|
||||
|
||||
private static ApprovalInfo fromApprovalInfo(ChangeJson.ApprovalInfo ai) {
|
||||
ApprovalInfo ao = new ApprovalInfo();
|
||||
ao.value = ai.value;
|
||||
ao.date = ai.date;
|
||||
fromAccount(ai, ao);
|
||||
return ao;
|
||||
}
|
||||
|
||||
private static AccountInfo fromAcountInfo(
|
||||
com.google.gerrit.server.account.AccountInfo i) {
|
||||
AccountInfo ai = new AccountInfo();
|
||||
fromAccount(i, ai);
|
||||
return ai;
|
||||
}
|
||||
|
||||
private static void fromAccount(
|
||||
com.google.gerrit.server.account.AccountInfo i, AccountInfo ai) {
|
||||
ai._accountId = i._accountId;
|
||||
ai.email = i.email;
|
||||
ai.name = i.name;
|
||||
ai.username = i.username;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,12 @@ import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.common.data.PermissionRange;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.common.FetchInfo;
|
||||
import com.google.gerrit.extensions.common.GitPerson;
|
||||
import com.google.gerrit.extensions.common.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.RevisionInfo;
|
||||
import com.google.gerrit.extensions.config.DownloadCommand;
|
||||
import com.google.gerrit.extensions.config.DownloadScheme;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
@@ -75,7 +80,6 @@ import com.google.gerrit.server.AnonymousUser;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gerrit.server.actions.ActionInfo;
|
||||
import com.google.gerrit.server.extensions.webui.UiActions;
|
||||
import com.google.gerrit.server.git.LabelNormalizer;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
@@ -917,7 +921,7 @@ public class ChangeJson {
|
||||
DownloadCommand command = e2.getProvider().get();
|
||||
String c = command.getCommand(scheme, projectName, refName);
|
||||
if (c != null) {
|
||||
fetchInfo.addCommand(commandName, c);
|
||||
addCommand(fetchInfo, commandName, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -926,6 +930,13 @@ public class ChangeJson {
|
||||
return r;
|
||||
}
|
||||
|
||||
private void addCommand(FetchInfo fetchInfo, String commandName, String c) {
|
||||
if (fetchInfo.commands == null) {
|
||||
fetchInfo.commands = Maps.newTreeMap();
|
||||
}
|
||||
fetchInfo.commands.put(commandName, c);
|
||||
}
|
||||
|
||||
private static GitPerson toGitPerson(UserIdentity committer) {
|
||||
GitPerson p = new GitPerson();
|
||||
p.name = committer.getName();
|
||||
@@ -975,52 +986,6 @@ public class ChangeJson {
|
||||
}
|
||||
}
|
||||
|
||||
public static class RevisionInfo {
|
||||
private transient boolean isCurrent;
|
||||
public Boolean draft;
|
||||
public Boolean hasDraftComments;
|
||||
public int _number;
|
||||
public Map<String, FetchInfo> fetch;
|
||||
public CommitInfo commit;
|
||||
public Map<String, FileInfoJson.FileInfo> files;
|
||||
public Map<String, ActionInfo> actions;
|
||||
}
|
||||
|
||||
public static class FetchInfo {
|
||||
public String url;
|
||||
public String ref;
|
||||
public Map<String, String> commands;
|
||||
|
||||
FetchInfo(String url, String ref) {
|
||||
this.url = url;
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
void addCommand(String name, String command) {
|
||||
if (commands == null) {
|
||||
commands = Maps.newTreeMap();
|
||||
}
|
||||
commands.put(name, command);
|
||||
}
|
||||
}
|
||||
|
||||
public static class GitPerson {
|
||||
public String name;
|
||||
public String email;
|
||||
public Timestamp date;
|
||||
public int tz;
|
||||
}
|
||||
|
||||
public static class CommitInfo {
|
||||
public final String kind = "gerritcodereview#commit";
|
||||
public String commit;
|
||||
public List<CommitInfo> parents;
|
||||
public GitPerson author;
|
||||
public GitPerson committer;
|
||||
public String subject;
|
||||
public String message;
|
||||
}
|
||||
|
||||
public static class LabelInfo {
|
||||
transient SubmitRecord.Label.Status _status;
|
||||
|
||||
|
||||
@@ -16,10 +16,11 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Patch;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference.Whitespace;
|
||||
import com.google.gerrit.server.patch.PatchList;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListEntry;
|
||||
@@ -55,7 +56,7 @@ public class FileInfoJson {
|
||||
|
||||
Map<String, FileInfo> files = Maps.newTreeMap();
|
||||
for (PatchListEntry e : list.getPatches()) {
|
||||
FileInfoJson.FileInfo d = new FileInfoJson.FileInfo();
|
||||
FileInfo d = new FileInfo();
|
||||
d.status = e.getChangeType() != Patch.ChangeType.MODIFIED
|
||||
? e.getChangeType().getCode() : null;
|
||||
d.oldPath = e.getOldName();
|
||||
@@ -66,7 +67,7 @@ public class FileInfoJson {
|
||||
d.linesDeleted = e.getDeletions() > 0 ? e.getDeletions() : null;
|
||||
}
|
||||
|
||||
FileInfoJson.FileInfo o = files.put(e.getNewName(), d);
|
||||
FileInfo o = files.put(e.getNewName(), d);
|
||||
if (o != null) {
|
||||
// This should only happen on a delete-add break created by JGit
|
||||
// when the file was rewritten and too little content survived. Write
|
||||
@@ -85,12 +86,4 @@ public class FileInfoJson {
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
static class FileInfo {
|
||||
Character status;
|
||||
Boolean binary;
|
||||
String oldPath;
|
||||
Integer linesInserted;
|
||||
Integer linesDeleted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -33,7 +34,6 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.change.FileInfoJson.FileInfo;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.patch.PatchList;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.restapi.CacheControl;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.change.ChangeJson.CommitInfo;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -20,13 +20,13 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
import com.google.gerrit.extensions.common.GitPerson;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetAncestor;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.change.ChangeJson.CommitInfo;
|
||||
import com.google.gerrit.server.change.ChangeJson.GitPerson;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gerrit.server.project.ProjectControl;
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.project;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap.Entry;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
@@ -24,7 +25,6 @@ import com.google.gerrit.extensions.webui.UiAction;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||
import com.google.gerrit.reviewdb.client.Project.SubmitType;
|
||||
import com.google.gerrit.server.actions.ActionInfo;
|
||||
import com.google.gerrit.server.config.AllProjectsNameProvider;
|
||||
import com.google.gerrit.server.config.PluginConfig;
|
||||
import com.google.gerrit.server.config.PluginConfigFactory;
|
||||
|
||||
Reference in New Issue
Block a user