Skip to content

Commit

Permalink
Revert "improvement: allow custom workflow branch name prefix (#1494)"
Browse files Browse the repository at this point in the history
This reverts commit da0f520.
  • Loading branch information
erquhart committed Sep 17, 2018
1 parent f8cdb6a commit a28ed72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 33 deletions.
7 changes: 4 additions & 3 deletions packages/netlify-cms-backend-github/src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -90,7 +91,7 @@ export default class API {
}

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

checkMetadataRef() {
Expand Down Expand Up @@ -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 = {}) {
Expand Down
7 changes: 2 additions & 5 deletions packages/netlify-cms-backend-github/src/implementation.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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']);
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
25 changes: 0 additions & 25 deletions website/content/docs/beta-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
```

0 comments on commit a28ed72

Please sign in to comment.