-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add branch name max length option to GitHub backend (closes #526) #862
Conversation
Deploy preview ready! Built with commit 45b1598 |
src/backends/github/API.js
Outdated
truncateSlugForBranchName(slug) { | ||
const slugMaxLength = this.branchNameMaxLength - CMS_BRANCH_PREFIX.length; | ||
return slug.length > slugMaxLength | ||
? slug.substring(0, slugMaxLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just take out the ternary here? If the string is smaller than it, shouldn't the string just be left as-is? I'm not experienced enough with JS string behavior to know whether that is the case or not, but it seems to be.
c8d10cf
to
ca1ecc5
Compare
@tech4him1 addressed your comment, please re-review. |
src/backends/github/API.js
Outdated
@@ -15,6 +15,7 @@ export default class API { | |||
this.branch = config.branch || "master"; | |||
this.repo = config.repo || ""; | |||
this.repoURL = `/repos/${ this.repo }`; | |||
this.branchNameMaxLength = (config.backend && config.backend.branchNameMaxLength) || 40; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you actually test this line? I'm not sure how it works, seeing that config
is not the actual config.yml, only the values that are passed in here: https://github.com/netlify/netlify-cms/blob/ca1ecc5fc04afdaad4726c2d0eb71e402f6e19a9/src/backends/github/implementation.js#L33
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we need to start rooting out ambiguous variable names like this, there's a lot of it in our source.
ca1ecc5
to
45b1598
Compare
Deploy preview ready! Built with commit 45b1598 |
@Benaiah Sorry for the delay. I'm seeing two things right now, one needs to be handled and one may not be: If the If the |
I would say we aren't set up for branch names to change, so updating that config should only affect new branches and not existing branches. |
@erquhart I agree, do you have any suggestions on how that could be implemented? |
Only reference/enforce it when creating branches. |
@erquhart I don't see how that works. If we save the metadata to a truncated name, how do we know what to get it back with without truncating? For example, if the slug is |
I may be under thinking this, but I'd expect we'd set the same name for metadata and branch? Sent with GitHawk |
Well, that's not really what I'm trying to point out, but I could be wrong. If we call |
Hmm we'd need to find a way to avoid truncating for read purposes, maybe through changing the metadata we track so the branch name itself is recorded. Sent with GitHawk |
That's the thing -- this PR currently truncates both the metadata filename and the branch name. |
Ah, understood! We shouldn't do that, agreed. |
Also, do you still think the best way to track the branch name is by saving in the metadata, or do you have other suggestions here? |
Haven't dug into it very deep, but I can't think of a better way at the moment. You? |
Closing as stale. |
- Summary
Adds branch name max length option to GitHub backend. Closes #526.
- Test plan
Tested manually.
- Description for the changelog