Merge "Allow to define default code owners across branches in refs/meta/config"
diff --git a/ui/code-owners-service.js b/ui/code-owners-service.js
index d690fcb..416b3ec 100644
--- a/ui/code-owners-service.js
+++ b/ui/code-owners-service.js
@@ -121,6 +121,21 @@
`/projects/${encodeURIComponent(project)}/code_owners.project_config`
);
}
+
+ /**
+ * Returns a promise fetching the owners config for a given branch.
+ *
+ * @doc https://gerrit.googlesource.com/plugins/code-owners/+/refs/heads/master/resources/Documentation/rest-api.md#branch-endpoints
+ * @param {string} project
+ * @param {string} branch
+ */
+ getBranchConfig(project, branch) {
+ return this.restApi.get(
+ `/projects/${encodeURIComponent(project)}/` +
+ `branches/${encodeURIComponent(branch)}/` +
+ `code_owners.branch_config`
+ );
+ }
}
/**
@@ -475,21 +490,22 @@
return this.getProjectConfigPromise;
}
+ getBranchConfig() {
+ if (!this.getBranchConfigPromise) {
+ this.getBranchConfigPromise =
+ this.codeOwnerApi.getBranchConfig(this.change.project,
+ this.change.branch);
+ }
+ return this.getBranchConfigPromise;
+ }
+
isCodeOwnerEnabled() {
if (this.change.status === ChangeStatus.ABANDONED ||
this.change.status === ChangeStatus.MERGED) {
return Promise.resolve(false);
}
- return this.getProjectConfig().then(config => {
- if (config.status && config.status.disabled) {
- return false;
- }
- if (config.status
- && config.status.disabled_branches
- && config.status.disabled_branches.includes(this.change.branch)) {
- return false;
- }
- return true;
+ return this.getBranchConfig().then(config => {
+ return !(config.status && config.status.disabled);
});
}
diff --git a/ui/owner-requirement.js b/ui/owner-requirement.js
index 04ac8f5..7bd74ee 100644
--- a/ui/owner-requirement.js
+++ b/ui/owner-requirement.js
@@ -105,7 +105,7 @@
}
_checkIfOverriden() {
- this.ownerService.getProjectConfig().then(res => {
+ this.ownerService.getBranchConfig().then(res => {
if (!res['override_approval']) {
// no override label configured
this._isOverriden = false;
@@ -150,7 +150,7 @@
}
_updateOverrideInfoUrl() {
- this.ownerService.getProjectConfig().then(config => {
+ this.ownerService.getBranchConfig().then(config => {
this._overrideInfoUrl = config.general && config.general.override_info_url
?
config.general.override_info_url : '';