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

fix: git-cz commit repoPath #676

Merged
merged 26 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b4b492b
fix: git-cz commit repoPath
shixy96 Oct 6, 2019
f322e2c
chore(deps): bump minimist from 1.2.0 to 1.2.3 (#721)
dependabot[bot] Apr 6, 2020
bd5a0ba
chore(deps): update dependency nyc to v15 (#704)
renovate[bot] Apr 6, 2020
7642f05
fix: add babel spread plugin
jimthedev Apr 7, 2020
9ae386c
fix: move to babel.config.js
jimthedev Apr 7, 2020
607d514
fix: update azure devops images
jimthedev Apr 7, 2020
09ade00
docs: add commitiquette (#727)
martinmcwhorter Apr 16, 2020
ce1042e
fix(deps): bump vulnerable packages
LinusU Apr 30, 2020
6ef8afa
feature: remove dependency on ShellJS (#729)
LinusU May 4, 2020
0f8644d
feat: remove dependency on ShellJS (#729)
LinusU May 4, 2020
a95fe72
fix(deps): update dependency cz-conventional-changelog to v3.2.0 (#657)
renovate[bot] May 5, 2020
a6adb3b
fix: restore commitizen.congifLoader.load to public API (#733)
LinusU May 5, 2020
be08907
fix: make cwd argument optional again (#735)
LinusU May 5, 2020
2954303
docs: add .czrc support to README (#739)
fsmaia Jul 6, 2020
367d709
fix(deps): upgrade lodash to 4.17.20 and update package lock file
Aug 20, 2020
a333b08
docs: add cz-format-extension (#758)
tyankatsu0105 Aug 21, 2020
2fbd7ea
docs: Update `commitlint` adapter link (#751)
chris-dura Aug 21, 2020
7a61389
docs: add adapter for jira (#748)
juliuscc Aug 21, 2020
c3a4542
chore(deps): update dependency nyc to v15.1.0 (#745)
renovate[bot] Aug 21, 2020
994f3b0
fix(cli): determine correct location of `COMMIT_EDITMSG` (#737)
wkunert Aug 21, 2020
33a77cc
chore(deps): update dependency babel-plugin-istanbul to v5.2.0 (#658)
renovate[bot] Aug 21, 2020
bf275d0
chore(deps): update dependency semver to v6.3.0 (#659)
renovate[bot] Aug 21, 2020
f7257f8
fix(deps): update dependency inquirer to v6.5.2 (#664)
renovate[bot] Aug 21, 2020
c3c533f
feat: use cz as binary name (#767)
felipecrs Aug 24, 2020
e223866
fix: git-cz commit repoPath
shixy96 Oct 6, 2019
23f9692
resolve conflicts
shixy96 Aug 25, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 26 additions & 13 deletions README.md
Expand Up @@ -22,20 +22,20 @@ npm install -g commitizen

### If your repo is [Commitizen-friendly]:

Simply use `git cz` instead of `git commit` when committing.
Simply use `git cz` or just `cz` instead of `git commit` when committing. You can also use `git-cz`, which is an alias for `cz`.

_Alternatively_, if you are using **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) instead of installing globally:

```
npx git-cz
npx cz
```

or as an npm script:

```json
...
"scripts": {
"commit": "npx git-cz"
"commit": "cz"
}
```

Expand All @@ -45,7 +45,7 @@ When you're working in a Commitizen friendly repository, you'll be prompted to f

### If your repo is NOT Commitizen friendly:

If you're **not** working in a Commitizen friendly repository, then `git cz` will work just the same as `git commit` but `npx git-cz` will use the [streamich/git-cz](https://github.com/streamich/git-cz) adapter. To fix this, you need to first [make your repo Commitizen-friendly](#making-your-repo-commitizen-friendly)
If you're **not** working in a Commitizen friendly repository, then `git cz` will work just the same as `git commit` but `npx cz` will use the [streamich/git-cz](https://github.com/streamich/git-cz) adapter. To fix this, you need to first [make your repo Commitizen-friendly](#making-your-repo-commitizen-friendly)

## Making your repo Commitizen-friendly

Expand Down Expand Up @@ -86,6 +86,14 @@ The above command does three things for you.
}
```

Alternatively, commitizen configs may be added to a .czrc file:

```json
{
"path": "cz-conventional-changelog"
}
```

This just tells Commitizen which adapter we actually want our contributors to use when they try to commit to this repo.

`commitizen.path` is resolved via [require.resolve](https://nodejs.org/api/globals.html#globals_require_resolve) and supports
Expand All @@ -110,7 +118,7 @@ On **NPM 5.2+** you can [use `npx`](https://medium.com/@maybekatz/introducing-np
npx commitizen init cz-conventional-changelog --save-dev --save-exact
```

For **previous versions of NPM (< 5.2)** you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/git-cz` in order to actually use the commands.
For **previous versions of NPM (< 5.2)** you can execute `./node_modules/.bin/commitizen` or `./node_modules/.bin/cz` in order to actually use the commands.

You can then initialize the conventional changelog adapter using: `./node_modules/.bin/commitizen init cz-conventional-changelog --save-dev --save-exact`

Expand All @@ -119,13 +127,15 @@ And you can then add some nice npm run scripts in your package.json pointing to
```json
...
"scripts": {
"commit": "git-cz"
"commit": "cz"
}
```

This will be more convenient for your users because then if they want to do a commit, all they need to do is run `npm run commit` and they will get the prompts needed to start a commit!

> **NOTE:** if you are using `precommit` hooks thanks to something like `husky`, you will need to name your script some thing other than "commit" (e.g. "cm": "git-cz"). The reason is because npm-scripts has a "feature" where it automatically runs scripts with the name *prexxx* where *xxx* is the name of another script. In essence, npm and husky will run "precommit" scripts twice if you name the script "commit," and the work around is to prevent the npm-triggered *precommit* script.
> **NOTE:** if you are using `precommit` hooks thanks to something like [`husky`](https://www.npmjs.com/package/husky), you will need to name your script some thing other than `"commit"`
> (e.g. `"cm": "cz"`). The reason is because npm-scripts has a "feature" where it automatically runs scripts with the name _prexxx_ where _xxx_ is the name of another script. In essence,
> npm and husky will run `"precommit"` scripts twice if you name the script `"commit"`, and the work around is to prevent the npm-triggered _precommit_ script.

#### Optional: Running Commitizen on `git commit`

Expand All @@ -142,10 +152,11 @@ Update `.git/hooks/prepare-commit-msg` with the following code:

```
#!/bin/bash
exec < /dev/tty && node_modules/.bin/git-cz --hook || true
exec < /dev/tty && node_modules/.bin/cz --hook || true
```

##### Husky

For `husky` users, add the following configuration to the project's `package.json`:

```
Expand Down Expand Up @@ -252,16 +263,19 @@ npm install company-commit --save-dev
We know that every project and build process has different requirements so we've tried to keep Commitizen open for extension. You can do this by choosing from any of the pre-build adapters or even by building your own. Here are some of the great adapters available to you:

- [cz-conventional-changelog](https://www.npmjs.com/package/cz-conventional-changelog)
- [cz-conventional-changelog-for-jira](https://www.npmjs.com/package/@digitalroute/cz-conventional-changelog-for-jira)
- [cz-jira-smart-commit](https://www.npmjs.com/package/cz-jira-smart-commit)
- [@endemolshinegroup/cz-jira-smart-commit](https://github.com/EndemolShineGroup/cz-jira-smart-commit)
- [@endemolshinegroup/cz-github](https://github.com/EndemolShineGroup/cz-github)
- [rb-conventional-changelog](https://www.npmjs.com/package/rb-conventional-changelog)
- [cz-mapbox-changelog](https://www.npmjs.com/package/cz-mapbox-changelog)
- [cz-customizable](https://github.com/leonardoanalista/cz-customizable)
- [commitlint](https://github.com/marionebl/commitlint)
- [commitlint](https://github.com/conventional-changelog/commitlint#tools)
- [vscode-commitizen](https://github.com/KnisterPeter/vscode-commitizen)
- [cz-emoji](https://github.com/ngryman/cz-emoji)
- [cz-adapter-eslint](https://www.npmjs.com/package/cz-adapter-eslint)
- [commitiquette](https://github.com/martinmcwhorter/commitiquette)
- [cz-format-extension](https://github.com/tyankatsu0105/cz-format-extension)

To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of [Inquirer.js](https://github.com/SBoudrias/Inquirer.js/) but you can capture input using whatever means necessary. Just call the `commit` callback with a string and we'll be happy. Publish it to npm, and you'll be all set!

Expand All @@ -271,11 +285,10 @@ As of version 2.7.1, you may attempt to retry the last commit using the `git cz

Please note that the retry cache may be cleared when upgrading commitizen versions, upgrading adapters, or if you delete the `commitizen.json` file in your home or temp directory. Additionally, the commit cache uses the filesystem path of the repo, so if you move a repo or change its path, you will not be able to retry a commit. This is an edge case, but might be confusing if you have scenarios where you are moving folders that contain repos.

It is important to note that if you are running `git-cz` from a npm script (let's say it is called `commit`) you will need to do one of the following:
It is important to note that if you are running `cz` from a npm script (let's say it is called `commit`) you will need to do one of the following:

- Pass `-- --retry` as an argument for your script. i.e: `npm run commit -- --retry`
- Use [npm-run](https://www.npmjs.com/package/npm-run) to find and call git-cz executable directly. i.e: `npm-run git-cz --retry`
- Use [npm-quick-run](https://www.npmjs.com/package/npm-quick-run) i.e: `nr commit --retry` or just `nr c --retry` (which will run all scripts that starts with the letter 'c')
- Use [npx](https://www.npmjs.com/package/npx) to find and call `cz` executable directly. i.e: `npx cz --retry`

Note that the last two options **do not** require you to pass `--` before the args but the first **does**.

Expand Down Expand Up @@ -340,4 +353,4 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
<a href="https://opencollective.com/commitizen/sponsor/8/website" target="_blank"><img src="https://opencollective.com/commitizen/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/commitizen/sponsor/9/website" target="_blank"><img src="https://opencollective.com/commitizen/sponsor/9/avatar.svg"></a>

[Commitizen-friendly]: #making-your-repo-commitizen-friendly
[commitizen-friendly]: #making-your-repo-commitizen-friendly
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Expand Up @@ -8,7 +8,7 @@ jobs:
parameters:
name: macOS
pool:
vmImage: 'macOS-10.13'
vmImage: 'macOS-latest'

- template: jobs/build.yml # Template reference
parameters:
Expand All @@ -20,5 +20,5 @@ jobs:
parameters:
name: Windows
pool:
vmImage: 'vs2017-win2016'
vmImage: 'windows-latest'
sign: true # Extra step on Windows only
13 changes: 13 additions & 0 deletions babel.config.js
@@ -0,0 +1,13 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "10",
},
},
],
],
plugins: ["@babel/plugin-proposal-object-rest-spread", "istanbul"],
};