Skip to content

Commit

Permalink
Fix multi branch github deployes by appending branch name for cms pul…
Browse files Browse the repository at this point in the history
…l requests.
  • Loading branch information
richtera committed Jul 10, 2018
1 parent 264b7ba commit 11f64f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/backends/github/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import AssetProxy from "ValueObjects/AssetProxy";
import { SIMPLE, EDITORIAL_WORKFLOW, status } from "Constants/publishModes";
import { APIError, EditorialWorkflowError } from "ValueObjects/errors";

const CMS_BRANCH_PREFIX = 'cms/';

export default class API {
constructor(config) {
this.api_root = config.api_root || "https://api.github.com";
this.token = config.token || false;
this.branch = config.branch || "master";
this.cms_branch_prefix = this.branch === 'master' ? 'cms/' : `cms-${this.branch}/`;
this.repo = config.repo || "";
this.repoURL = `/repos/${ this.repo }`;
this.merge_method = config.squash_merges ? "squash" : "merge";
Expand Down Expand Up @@ -91,7 +90,7 @@ export default class API {
}

generateBranchName(basename) {
return `${CMS_BRANCH_PREFIX}${basename}`;
return `${this.cms_branch_prefix}${basename}`;
}

checkMetadataRef() {
Expand Down Expand Up @@ -611,7 +610,7 @@ export default class API {
}

assertCmsBranch(branchName) {
return branchName.startsWith(CMS_BRANCH_PREFIX);
return branchName.startsWith(this.cms_branch_prefix);
}

patchBranch(branchName, sha, opts = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/backends/github/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default class GitHub {
const promises = [];
branches.map((branch) => {
promises.push(new Promise((resolve, reject) => {
const slug = branch.ref.split("refs/heads/cms/").pop();
const slug = branch.ref.split(`refs/heads/${this.api.cms_branch_prefix}`).pop();
return sem.take(() => this.api.readUnpublishedBranchFile(slug).then((data) => {
if (data === null || data === undefined) {
resolve(null);
Expand Down

0 comments on commit 11f64f4

Please sign in to comment.