Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CollectionName not prepended to branch names in Editorial Workflow mode #1396

Closed
shaunbent opened this issue May 31, 2018 · 6 comments · Fixed by #2878
Closed

CollectionName not prepended to branch names in Editorial Workflow mode #1396

shaunbent opened this issue May 31, 2018 · 6 comments · Fixed by #2878

Comments

@shaunbent
Copy link

- Do you want to request a feature or report a bug?

Bug

- What is the current behavior?

I have two collections which contain pages with the same names with different content. With the Editorial Workflow enabled changing any of these pages effects the other collections equivalent page.

I think I've worked out what is happening, it looks like the generated branch names do not contain the collectionName- as it suggests it should in the documentation.

At first I thought this was the same issue as #1164 but I actually think its different.

Looking at the code I think the problem is here: https://github.com/netlify/netlify-cms/blob/55a24a75c14fcef97b19f9c1fe6cc1579e0b59c2/src/backends/github/API.js#L325

It seem as just the slug is passed to the generateBranchName function and not options.collectionName as well. I might be wrong though.

So in my case instead of cms/pages-consumer/color, I get cms/color.

- If the current behavior is a bug, please provide the steps to reproduce.

  • Create two collections with pages/files of the same name
  • Make a change to a file in one collection and see the branch/PR created with the name cms/[name of file]
  • Try changing the corresponding file in the other collection and you should see the changes you made in the previous step.

- What is the expected behavior?

Branches should be created with the collectionName prepended to the branch name allowing them to be different.

- Please mention your versions where applicable.

Netlify CMS version: 1.8.4
Browser version: Chrome 66

Node.JS version: 9.8.0
Operating System: OS X

- Please link or paste your config.yml below if applicable.

@erquhart
Copy link
Contributor

erquhart commented Jun 7, 2018

Looks like a long standing regression from #145, thanks for pointing it out!

@nazihahmed
Copy link

nazihahmed commented Jun 14, 2018

a simple fix i made to our branch (in our case we had index.md for most collections), so i simply check if the slug is index and add to it the collectionName.
here is a ref which you can base your fix on:
in file API.js after line 281

      if (file.slug === "index") {
        file.slug = "index-" + file.path.match(/\/([\w-]+)\/index\.md$/)[1];
      }

the line file.path.match(/\/([\w-]+)\/index\.md$/)[1]; takes the collection name from the path, you will need to modify the code to work in your case for either to pass the collection name to this function somehow to to parse it out of the url

@erquhart
Copy link
Contributor

We'd definitely take a PR for this.

@nazihahmed
Copy link

I will work on that by the weekend..
it needs some changes, anyways happy to help

@erquhart
Copy link
Contributor

@nazihahmed that'd be awesome, reach out on Gitter if you need any help.

@stale
Copy link

stale bot commented Oct 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment