Adapt to auto values on Gerrit master
Recent Gerrit master has introduced auto values for the
implementation of the keys of the following classes:
Account.Id, Project.NameKey, Change.Id.
Adapt the creation and access to the key fields to make
the owners plugin work again on master.
Change-Id: I3ff3c545eea207239278c046a8e069372627edc3
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
index 22e3db8..7f5262a 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
+++ b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/GitRefListener.java
@@ -93,7 +93,7 @@
// The provider injected by Gerrit is shared with other workers on the
// same local thread and thus cannot be closed in this event listener.
try {
- ChangeApi cApi = changes.id(cId.id);
+ ChangeApi cApi = changes.id(cId.get());
ChangeInfo change = cApi.get();
if (change == null) {
return;
@@ -124,7 +124,7 @@
PatchListKey plKey = PatchListKey.againstCommit(null, newId, IGNORE_NONE);
try {
- return patchListCache.get(plKey, new Project.NameKey(change.project));
+ return patchListCache.get(plKey, Project.nameKey(change.project));
} catch (PatchListNotAvailableException e) {
logger.warn("Could not load patch list: {}", plKey, e);
}
diff --git a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
index 4a16316..6f97fdd 100644
--- a/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
+++ b/owners-autoassign/src/main/java/com/googlesource/gerrit/owners/common/ReviewerManager.java
@@ -50,7 +50,7 @@
try {
ChangeInfo changeInfo = cApi.get();
try (ManualRequestContext ctx =
- requestContext.openAs(new Account.Id(changeInfo.owner._accountId))) {
+ requestContext.openAs(Account.id(changeInfo.owner._accountId))) {
// TODO(davido): Switch back to using changes API again,
// when it supports batch mode for adding reviewers
ReviewInput in = new ReviewInput();
diff --git a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
index b5c1f90..a076125 100644
--- a/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
+++ b/owners-common/src/main/java/com/googlesource/gerrit/owners/common/AccountsImpl.java
@@ -64,7 +64,7 @@
this.byId = byId;
this.groupCache = groupCache;
this.groupMembers = groupMembers;
- this.adminUser = userFactory.create(new Account.Id(1000000));
+ this.adminUser = userFactory.create(Account.id(1000000));
this.oneOffRequestContext = oneOffRequestContext;
}
@@ -79,9 +79,9 @@
private Set<Id> findAccountsInGroup(String groupNameOrUUID) {
Optional<InternalGroup> group =
groupCache
- .get(new AccountGroup.NameKey(groupNameOrUUID))
+ .get(AccountGroup.nameKey(groupNameOrUUID))
.map(Optional::of)
- .orElse(groupCache.get(new AccountGroup.UUID(groupNameOrUUID)));
+ .orElse(groupCache.get(AccountGroup.uuid(groupNameOrUUID)));
if (!group.isPresent()) {
log.warn("Group {} was not found", groupNameOrUUID);
diff --git a/owners/src/main/java/com/googlesource/gerrit/owners/OwnersStoredValues.java b/owners/src/main/java/com/googlesource/gerrit/owners/OwnersStoredValues.java
index 18abe29..f721539 100644
--- a/owners/src/main/java/com/googlesource/gerrit/owners/OwnersStoredValues.java
+++ b/owners/src/main/java/com/googlesource/gerrit/owners/OwnersStoredValues.java
@@ -43,7 +43,7 @@
protected PathOwners createValue(Prolog engine) {
PatchList patchList = StoredValues.PATCH_LIST.get(engine);
Repository repository = StoredValues.REPOSITORY.get(engine);
- String branch = StoredValues.getChange(engine).getDest().get();
+ String branch = StoredValues.getChange(engine).getDest().branch();
return new PathOwners(accounts, repository, branch, patchList);
}
};