-
-
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
Enable user-configured commit message templates #1359
Enable user-configured commit message templates #1359
Conversation
Deploy preview for netlify-cms-www ready! Built with commit f45cec5 |
Deploy preview for cms-demo ready! Built with commit f45cec5 |
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.
Great PR, thanks for putting this together! Just one small change request. Agreed that documenting this under beta features makes sense for now.
@@ -283,9 +309,9 @@ class Backend { | |||
.then(() => entryObj.slug); | |||
} | |||
|
|||
persistMedia(file) { | |||
persistMedia(config, file) { |
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.
Switch the argument order for persistMedia
and deleteMedia
so the config is the last argument.
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.
Ok, will do. One note: I decided to pass config
as the first argument because that is what persistEntry
and deleteEntry
currently do. Not sure if inconsistency between entry and media actions is a concern.
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.
I should have asked why you did that - you're right, consistency first. Thanks for pointing that out.
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.
Ok, great. I’ll work on some documentation now.
@erquhart Ok, tried to document this. Would appreciate a few people reading through it, because it’s a little tricky to explain all the parts of this option. @verythorough Do you have any thoughts? |
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.
Sorry for the delay! I love how thorough these docs are. :)
I made one comment about the initial heading & description. Otherwise, looks good to me!
|
||
## Customizing Commit Messages | ||
You can customize the commit messages generated by Netlify CMS with templates in the `backend` option of your `config.yml`. | ||
|
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.
To me, "customize commit messages" implies editing individual messages, rather than the templates that generate them. I think it might be clearer if the above two lines become something more like:
Commit Message Templates
You can customize the templates used by Netlify CMS to generate commit messages by setting the
commit_messages
option underbackend
in yourconfig.yml
.
Awesome! 😄 |
Summary
Closes #557
Exposes a
backend.commit_messages
option, which allows users to configure the commit messages generated by Netlify CMS using string templates. Default behaviour remains unchanged and is equivalent to the following inconfig.yml
:Why?
Users may want Netlify CMS commits to be formatted in a specific way. For example, they might want to adhere to a commit message convention they are already using. More discussion can be found in #557.
To-do
Should this be under Beta Features?Considerations/Notes
Previously,
Discussed belowpersistEntry
anddeleteEntry
were passed aconfig
object (inactions/entries
), whilepersistMedia
anddeleteMedia
were not (inactions/mediaLibrary
). To allow configuration of commit messages for media uploading and deletion, I changedpersistMedia
anddeleteMedia
to also receive aconfig
object. For consistency with the entry methods, this is passed as their first argument. As far as I can tell, this only impactedactions/mediaLibrary
, which I updated accordingly (3e360d1).The variables available are pretty minimal and inconsistent based on what is available in each commit method at the moment. For entry commits,
slug
,path
, andcollection
are available, but for media commits only thepath
variable is available. It would be nice if this were all standardised somehow in the future with some kind of commit object holding more information.Netlify CMS also creates commit messages when merging and force merging pull requests in its GitHub API implementation. In theory, these messages should also be configurable, but perhaps that can wait?
Should the config option be elsewhere? @Benaiah mentioned a future
backend.settings
namespace for backend-specific options.I duplicated the string template logic from the
slugFormatter
. Given that this curly braces syntax is now in use in at least two places, perhaps the template-processing logic should be abstracted?Test plan
npm run test
passedone-click-hugo-cms
template)Description for the changelog
Enable user-configured commit message templates
A picture of a cute animal (not mandatory but encouraged)
A messenger pigeon 🐦