Apply refactorings and upgrade bazlets to latest
Upgrade bazlets to latest master to build with 3.0.0-rc1 API
Change-Id: I44a1ba8efb163894641694a614bc1ce4015b4a45
diff --git a/WORKSPACE b/WORKSPACE
index d752151..adb396d 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,7 +1,7 @@
workspace(name = "copyright")
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "f3b3eecf061193e8909298bc9c35027df3bf9d44",
+ commit = "8808e401a9c68a02ae541c36a36dd672a171b7e7"
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfig.java b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfig.java
index 11b3a3a..4a49b2d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfig.java
@@ -199,7 +199,7 @@
@Override
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent event)
throws CommitValidationException {
- if (!event.getBranchNameKey().get().equals(RefNames.REFS_CONFIG)) {
+ if (!event.getRefName().equals(RefNames.REFS_CONFIG)) {
return Collections.emptyList();
}
if (!event.getProjectNameKey().equals(allProjectsName)) {
@@ -378,7 +378,7 @@
}
ProjectState projectState;
try {
- projectState = projectCache.checkedGet(new Project.NameKey(project));
+ projectState = projectCache.checkedGet(Project.nameKey(project));
} catch (IOException e) {
logger.atSevere().withCause(e).log("error getting project state of %s", project);
// throw IllegalStateException? RestApiException?
diff --git a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightReviewApi.java b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightReviewApi.java
index 15a8364..318c893 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightReviewApi.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightReviewApi.java
@@ -468,7 +468,7 @@
PluginUser pluginUser = pluginUserProvider.get();
return fromAccountId <= 0
? userProvider.get()
- : identifiedUserFactory.runAs(null, new Account.Id(fromAccountId), pluginUser);
+ : identifiedUserFactory.runAs(null, Account.id(fromAccountId), pluginUser);
}
/**
@@ -643,8 +643,7 @@
throws RestApiException {
try {
CurrentUser fromUser = getSendingUser(fromAccountId);
- ChangeNotes notes =
- changeNotesFactory.createChecked(new Change.Id(event.getChange()._number));
+ ChangeNotes notes = changeNotesFactory.createChecked(Change.id(event.getChange()._number));
return changeResourceFactory.create(notes, fromUser);
} catch (Exception e) {
Throwables.throwIfUnchecked(e);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidator.java b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidator.java
index f17ed95..cd71e85 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidator.java
@@ -233,7 +233,7 @@
metrics.scanCountByProject.increment(project);
metrics.scanCountByBranch.increment(branch);
- try (Repository repo = repoManager.openRepository(new Project.NameKey(project));
+ try (Repository repo = repoManager.openRepository(Project.nameKey(project));
RevWalk revWalk = new RevWalk(repo);
TreeWalk tw = new TreeWalk(revWalk.getObjectReader())) {
RevCommit commit = repo.parseCommit(ObjectId.fromString(event.getRevision().commit.commit));
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
index fb5bcd6..3b5d5f4 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightConfigIT.java
@@ -354,7 +354,7 @@
}
private AccountGroup.Id nextGroupId() {
- return new AccountGroup.Id(nextId++);
+ return AccountGroup.id(nextId++);
}
private TestRepository<InMemoryRepository> getTestRepo(Project.NameKey projectName)
@@ -366,7 +366,7 @@
}
private InternalGroup testGroup(String name) throws Exception {
- AccountGroup.NameKey nameKey = new AccountGroup.NameKey(name);
+ AccountGroup.NameKey nameKey = AccountGroup.nameKey(name);
Optional<InternalGroup> g = groupCache.get(nameKey);
if (g.isPresent()) {
return g.get();
@@ -374,7 +374,7 @@
GroupsUpdate groupsUpdate = groupsUpdateProvider.get();
InternalGroupCreation gc =
InternalGroupCreation.builder()
- .setGroupUUID(new AccountGroup.UUID("users-" + name.replace(" ", "_")))
+ .setGroupUUID(AccountGroup.uuid("users-" + name.replace(" ", "_")))
.setNameKey(nameKey)
.setId(nextGroupId())
.build();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
index 681ed26..61bfb8e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/copyright/CopyrightValidatorIT.java
@@ -404,7 +404,7 @@
}
private AccountGroup.Id nextGroupId() {
- return new AccountGroup.Id(nextId++);
+ return AccountGroup.id(nextId++);
}
private TestRepository<InMemoryRepository> getTestRepo(Project.NameKey projectName)
@@ -416,7 +416,7 @@
}
private InternalGroup testGroup(String name) throws Exception {
- AccountGroup.NameKey nameKey = new AccountGroup.NameKey(name);
+ AccountGroup.NameKey nameKey = AccountGroup.nameKey(name);
Optional<InternalGroup> g = groupCache.get(nameKey);
if (g.isPresent()) {
return g.get();
@@ -424,7 +424,7 @@
GroupsUpdate groupsUpdate = groupsUpdateProvider.get();
InternalGroupCreation gc =
InternalGroupCreation.builder()
- .setGroupUUID(new AccountGroup.UUID("users-" + name.replace(" ", "_")))
+ .setGroupUUID(AccountGroup.uuid("users-" + name.replace(" ", "_")))
.setNameKey(nameKey)
.setId(nextGroupId())
.build();