CodeOwnerConfig: Rename branch to branchNameKey
This makes it more explicit that it's project + branch and not only the
branch.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I92d44cb141397c0a69de743b7250682b23aceb75
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
index 9cdd520..57fcb6b 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfig.java
@@ -211,8 +211,8 @@
*/
@AutoValue
public abstract static class Key {
- /** Gets the branch to which the code owner config belongs. */
- public abstract BranchNameKey branch();
+ /** Gets the project and branch to which the code owner config belongs. */
+ public abstract BranchNameKey branchNameKey();
/**
* Gets the path of the folder to which the code owner config belongs.
@@ -234,7 +234,7 @@
* @return the project to which the code owner config belongs
*/
public Project.NameKey project() {
- return branch().project();
+ return branchNameKey().project();
}
/**
@@ -243,7 +243,7 @@
* @return the short name of the branch of this owner config key
*/
public String shortBranchName() {
- return branch().shortName();
+ return branchNameKey().shortName();
}
/**
@@ -252,7 +252,7 @@
* @return the ref name of the branch to which the code owner config belongs
*/
public String ref() {
- return branch().branch();
+ return branchNameKey().branch();
}
/**
@@ -298,14 +298,14 @@
/**
* Creates a code owner config key.
*
- * @param branch the branch to which the code owner config belongs
+ * @param branchNameKey the project and branch to which the code owner config belongs
* @param folderPath the path of the folder to which the code owner config belongs, must be
* absolute
* @return the code owner config key
*/
- public static Key create(BranchNameKey branch, Path folderPath) {
+ public static Key create(BranchNameKey branchNameKey, Path folderPath) {
return new AutoValue_CodeOwnerConfig_Key.Builder()
- .setBranch(branch)
+ .setBranchNameKey(branchNameKey)
.setFolderPath(folderPath)
.build();
}
@@ -313,15 +313,15 @@
/**
* Creates a code owner config key.
*
- * @param branch the branch to which the code owner config belongs
+ * @param branchNameKey the project and branch to which the code owner config belongs
* @param folderPath the path of the folder to which the code owner config belongs, must be
* absolute
* @param fileName the name of the code owner config file
* @return the code owner config key
*/
- public static Key create(BranchNameKey branch, Path folderPath, String fileName) {
+ public static Key create(BranchNameKey branchNameKey, Path folderPath, String fileName) {
return new AutoValue_CodeOwnerConfig_Key.Builder()
- .setBranch(branch)
+ .setBranchNameKey(branchNameKey)
.setFolderPath(folderPath)
.setFileName(fileName)
.build();
@@ -330,12 +330,12 @@
@AutoValue.Builder
abstract static class Builder {
/**
- * Sets the branch for this owner config key.
+ * Sets the project and branch for this owner config key.
*
- * @param branch the branch for this owner config key
+ * @param branchNameKey the project and branch for this owner config key
* @return the Builder instance for chaining calls
*/
- public abstract Builder setBranch(BranchNameKey branch);
+ public abstract Builder setBranchNameKey(BranchNameKey branchNameKey);
/**
* Sets the folder path for this owner config key.
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
index 4010dca..9d9ca55 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigFile.java
@@ -147,7 +147,7 @@
@Override
protected String getRefName() {
- return codeOwnerConfigKey.branch().branch();
+ return codeOwnerConfigKey.branchNameKey().branch();
}
@Override
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwners.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwners.java
index 73fc6a4..0c38ef4 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwners.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwners.java
@@ -52,7 +52,7 @@
requireNonNull(codeOwnerConfigKey, "codeOwnerConfigKey");
requireNonNull(revision, "revision");
CodeOwnerBackend codeOwnerBackend =
- codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branch());
+ codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branchNameKey());
return codeOwnerBackend.getCodeOwnerConfig(codeOwnerConfigKey, revision);
}
@@ -66,7 +66,7 @@
public Optional<CodeOwnerConfig> getFromCurrentRevision(CodeOwnerConfig.Key codeOwnerConfigKey) {
requireNonNull(codeOwnerConfigKey, "codeOwnerConfigKey");
CodeOwnerBackend codeOwnerBackend =
- codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branch());
+ codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branchNameKey());
return codeOwnerBackend.getCodeOwnerConfig(codeOwnerConfigKey, null);
}
}
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersUpdate.java b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersUpdate.java
index 3546298..e123b84 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersUpdate.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/CodeOwnersUpdate.java
@@ -96,7 +96,7 @@
public Optional<CodeOwnerConfig> upsertCodeOwnerConfig(
CodeOwnerConfig.Key codeOwnerConfigKey, CodeOwnerConfigUpdate codeOwnerConfigUpdate) {
CodeOwnerBackend codeOwnerBackend =
- codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branch());
+ codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branchNameKey());
return codeOwnerBackend.upsertCodeOwnerConfig(
codeOwnerConfigKey, codeOwnerConfigUpdate, currentUser.orElse(null));
}
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java b/java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java
index aac8d22..86dca27 100644
--- a/java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java
+++ b/java/com/google/gerrit/plugins/codeowners/backend/PathCodeOwners.java
@@ -79,7 +79,7 @@
*/
private PathExpressionMatcher getMatcher(CodeOwnerConfig.Key codeOwnerConfigKey) {
CodeOwnerBackend codeOwnerBackend =
- codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branch());
+ codeOwnersPluginConfiguration.getBackend(codeOwnerConfigKey.branchNameKey());
return codeOwnerBackend
.getPathExpressionMatcher()
.orElse((pathExpression, relativePath) -> false);