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

feat(config): add the ability to customize commit messages #612

Merged
merged 3 commits into from
Feb 9, 2018

Conversation

Arcanemagus
Copy link
Contributor

@Arcanemagus Arcanemagus commented Feb 7, 2018

Add configuration options allowing Greenkeeper's commit message format to be customized as the user desires. These are handled exactly like other configuration options, as a commitMessages key in package.json. Some messages support data coming in, the format for this follows JavaScript's template literals.

This will allow Greenkeeper to fit in with any custom commit message format that a project requires, instead of forcing the conventional-commit style.

Within package.json the following keys are used as the default values:

{
  "greenkeeper": {
    "commitMessages": {
      "initialBadge": "docs(readme): add Greenkeeper badge",
      "initialDependencies": "chore(package): update dependencies",
      "initialBranches": "chore(travis): whitelist greenkeeper branches",
      "dependencyUpdate": "fix(package): update ${dependency} to version ${version}",
      "devDependencyUpdate": "chore(package): update ${dependency} to version ${version}",
      "dependencyPin": "fix: pin ${dependency} to ${oldVersion}",
      "devDependencyPin": "chore: pin ${dependency} to ${oldVersion}",
      "closes": "\n\nCloses #${number}"
    }
  }
}

Note: closes is somewhat special in that it is conditionally appended to (dev)dependencyUpdate and doesn't get used on its own.

The values within ${} for each message are passed in from the appropriate places within the code, they can be omitted, but the variable names can't be changed from the configuration.

  • dependencyUpdate and devDependencyUpdate support these parameters:
    • dependency
    • version
  • dependencyPin and devDependencyPin support these parameters:
    • dependency
    • oldVersion
  • closes supports a number parameter denoting the PR it closes.

As an example usage to have Greenkeeper follow ESLint convention (#608), the following configuration could be used:

{
  "greenkeeper": {
    "commitMessages": {
      "initialBadge": "Docs: Add Greenkeeper badge",
      "initialDependencies": "Upgrade: Update dependencies",
      "initialBranches": "Build: Whitelist greenkeeper branches",
      "dependencyUpdate": "Upgrade: Update ${dependency} to version ${version}",
      "devDependencyUpdate": "Upgrade: Update ${dependency} to version ${version}",
      "dependencyPin": "Fix: Pin ${dependency} to ${oldVersion}",
      "devDependencyPin": "Fix: Pin ${dependency} to ${oldVersion}"
    }
  }
}

Note: Since closes is the same as the default, there is no need to specify it here.
Note: #608 was talking about an "(extended) ESLint" configuration, the above follows this guide.

Fixes #153.

@Arcanemagus
Copy link
Contributor Author

Hopefully this works, the test scripts are completely broken on Windows 😛.

Add configuration options allowing Greenkeeper's commit message format
to be customized as the user desires. These are handled exactly like
other configuration options, as a `commitMessages` key in
`package.json`. Some messages support data coming in, the format for
this follows JavaScript's template literals.

This will allow Greenkeeper to fit in with any custom commit message
format that a project requires, instead of forcing the
conventional-commit style.

Fixes greenkeeperio#153.
@Arcanemagus
Copy link
Contributor Author

Arcanemagus commented Feb 7, 2018

It looks like third party PR's don't get a valid PRIVATE_KEY, so they can't run the tests.

@Realtin
Copy link
Member

Realtin commented Feb 8, 2018

@Arcanemagus I updated the Travis config and it now runs the pr correctly. I had to 'unsecure' the PRIVATE_KEY, which is ok since it is just a randomly generated one anyway!

I only had a brief look on the PR and noticed that lodash has a function _.template which seems to be the same as es6-template-strings and we already have lodash so you could use that instead. The other module seems to not be tested on newer node versions (7+).

Tests are failing unfortunately, I can try to dig into it on the weekend.

Instead of bringing in an additional library, use the Lodash `template`
function since the library is already used elsewhere in the project.
Remove the async designation from `get-message`, this function is purely
sync.
@Arcanemagus
Copy link
Contributor Author

@Realtin Changed this over to _.template and fixed the code 😉, thanks for fixing the builds!

Copy link
Member

@Realtin Realtin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work ✨
Thank you so much for spending time on this.

When you made the changes, I merge it, which means it will be deployed to our staging system and tested it on there. If everything runs smoothly, I can deploy it to production as soon as next week!

package.json Outdated
@@ -9,6 +9,7 @@
"catbox-memory": "^2.0.4",
"couchdb-bootstrap": "^1.14.0",
"envalid": "^4.0.1",
"es6-template-strings": "^2.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed removing the package from the package.json :)

@Realtin
Copy link
Member

Realtin commented Feb 8, 2018

I looked at an outdated diff 😅

@Realtin Realtin merged commit 1704eac into greenkeeperio:master Feb 9, 2018
@Arcanemagus Arcanemagus deleted the commit-message-style branch February 9, 2018 16:47
@jy95
Copy link

jy95 commented Feb 13, 2018

Does the bot greenkeeper[bot] has the latest version ?
I set up a new repo with @Arcanemagus ESlint example and it seems Angular convention is still prefered.

@Realtin
Copy link
Member

Realtin commented Feb 14, 2018

Hey, the feature is not yet deployed to production. I'll ping you on the issue when it is.

@Realtin
Copy link
Member

Realtin commented Feb 21, 2018

@jy95 @Arcanemagus It's released on production now! 🚀 ✨ 📝
We will officially advertise it as soon as we wrote up some documentation for the FAQ :)

@jy95
Copy link

jy95 commented Feb 23, 2018

Thanks @Realtin Work as expected on my test repo : https://github.com/jy95/mediaScan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow customization of commit messages & pull requests
3 participants