From a28ed726aae9fbd4ff193e33e102ddb30b8aa3fc Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Mon, 17 Sep 2018 12:19:14 -0400 Subject: [PATCH] Revert "improvement: allow custom workflow branch name prefix (#1494)" This reverts commit da0f520f0d4f7af0e0ec8af16fbdd04bc39751b4. --- .../netlify-cms-backend-github/src/API.js | 7 +++--- .../src/implementation.js | 7 ++---- website/content/docs/beta-features.md | 25 ------------------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/packages/netlify-cms-backend-github/src/API.js b/packages/netlify-cms-backend-github/src/API.js index 602dd1dc..5fc084b6 100644 --- a/packages/netlify-cms-backend-github/src/API.js +++ b/packages/netlify-cms-backend-github/src/API.js @@ -4,12 +4,13 @@ import { uniq, initial, last, get, find, hasIn, partial, result } from 'lodash'; import { filterPromises, resolvePromiseProperties } from 'netlify-cms-lib-util'; import { APIError, EditorialWorkflowError } from 'netlify-cms-lib-util'; +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.workflow_branch_prefix = config.workflow_branch_prefix; this.repo = config.repo || ''; this.repoURL = `/repos/${this.repo}`; this.merge_method = config.squash_merges ? 'squash' : 'merge'; @@ -90,7 +91,7 @@ export default class API { } generateBranchName(basename) { - return `${this.workflow_branch_prefix}/${basename}`; + return `${CMS_BRANCH_PREFIX}${basename}`; } checkMetadataRef() { @@ -649,7 +650,7 @@ export default class API { } assertCmsBranch(branchName) { - return branchName.startsWith(`${this.workflow_branch_prefix}/`); + return branchName.startsWith(CMS_BRANCH_PREFIX); } patchBranch(branchName, sha, opts = {}) { diff --git a/packages/netlify-cms-backend-github/src/implementation.js b/packages/netlify-cms-backend-github/src/implementation.js index c0fecd89..ff0719ca 100644 --- a/packages/netlify-cms-backend-github/src/implementation.js +++ b/packages/netlify-cms-backend-github/src/implementation.js @@ -1,4 +1,4 @@ -import { trim, trimStart } from 'lodash'; +import trimStart from 'lodash/trimStart'; import semaphore from 'semaphore'; import AuthenticationPage from './AuthenticationPage'; import API from './API'; @@ -22,8 +22,6 @@ export default class GitHub { this.repo = config.getIn(['backend', 'repo'], ''); this.branch = config.getIn(['backend', 'branch'], 'master').trim(); - this.workflow_branch_prefix = - trim(config.getIn(['backend', 'workflow_branch_prefix'], ''), '/ ') || 'cms'; this.api_root = config.getIn(['backend', 'api_root'], 'https://api.github.com'); this.token = ''; this.squash_merges = config.getIn(['backend', 'squash_merges']); @@ -42,7 +40,6 @@ export default class GitHub { this.api = new API({ token: this.token, branch: this.branch, - workflow_branch_prefix: this.workflow_branch_prefix, repo: this.repo, api_root: this.api_root, squash_merges: this.squash_merges, @@ -161,7 +158,7 @@ export default class GitHub { branches.map(branch => { promises.push( new Promise(resolve => { - const slug = branch.ref.split(`refs/heads/${this.workflow_branch_prefix}/`).pop(); + const slug = branch.ref.split('refs/heads/cms/').pop(); return sem.take(() => this.api .readUnpublishedBranchFile(slug) diff --git a/website/content/docs/beta-features.md b/website/content/docs/beta-features.md index c20b8e80..e19932b7 100644 --- a/website/content/docs/beta-features.md +++ b/website/content/docs/beta-features.md @@ -120,28 +120,3 @@ Template tags produce the following output: - `{{collection}}`: the name of the collection containing the entry changed - `{{path}}`: the full path to the file changed - -## Custom Editorial Workflow branch name prefixes - -When using [editorial workflow](), a branch is created for each entry. By default the branch name -follows this template: - -``` -cms/{{slug}} -``` - -You can customize the `cms` portion by setting `workflow_branch_prefix` under `backend` in your -`config.yml`: - -```yaml -backend: - name: some-backend - branch: dev - workflow_branch_prefix: cms-dev -``` - -The above configuration would change the branch name template to: - -``` -cms-dev/{{slug}} -``` \ No newline at end of file