Skip to content

Commit 23a7ae7

Browse files
committed
feat(main): support git-duet
1 parent 0725454 commit 23a7ae7

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $ npm install -g git-consistent
1212
$ yarn global add git-consistent
1313
1414
# options
15-
$ git config --global alias.con consistent
15+
$ git config --global alias.con "consistent -i"
1616
```
1717

1818
## Usage
@@ -79,7 +79,8 @@ This is amazing feature.
7979

8080
| Option | Default | Description |
8181
| ------ | ------- | ----------- |
82-
| `-d, --dry-run` | false | run dry-run mode |
82+
| `-d, --duet` | false | run git-duet mode |
83+
| `-D, --dry-run` | false | run dry-run mode |
8384
| `-i, --interactive` | false | run interactive mode |
8485
| `-s, --skip-options` | false | skip not required term input (interactive mode only) |
8586
| `-V, --version` | | output the version number |
@@ -106,6 +107,23 @@ scope:
106107
suffix: ')'
107108
```
108109
110+
### git-duet
111+
112+
Run [git-duet](https://github.com/git-duet/git-duet) mode when with `-d` option.
113+
114+
```sh
115+
$ git consistent -d --type"feat" --subject="duet test" --body=""
116+
```
117+
118+
```
119+
Author: isuke <isuke770@gmail.com>
120+
Date: Sat Feb 10 15:13:40 2018 +0900
121+
122+
feat: duet test
123+
124+
Signed-off-by: foo <foo@example.con>
125+
```
126+
109127
---
110128
111129
# TODO
@@ -123,8 +141,6 @@ You should select follow values.
123141
'feat', 'fix', 'docs' and 'refactor'.
124142
```
125143

126-
### support [git-duet](https://github.com/git-duet/git-duet)
127-
128144
## develop
129145
### test
130146

git-consistent

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ const setOptions = (program, definitions, terms) => {
4646

4747
const createProgram = (program, definitions, terms) => {
4848
return setOptions(program, definitions, terms)
49-
.option(`-d, --dry-run`, 'run dry-run mode', false)
49+
.option(`-d, --duet`, 'run git-duet mode', false)
50+
.option(`-D, --dry-run`, 'run dry-run mode', false)
5051
.option(`-i, --interactive`, 'run interactive mode', false)
5152
.option(`-s, --skip-options`, 'skip not required term input (interactive mode only)', false)
5253
.version(version)
@@ -147,19 +148,21 @@ const replaceTerm = (program, template, definition, term) => {
147148
return _.replace(template, `<${term}>`, decoratedValue)
148149
}
149150

150-
const gitCommit = (commitMessage, dryRun = false) => {
151+
const gitCommit = (commitMessage, duet = false, dryRun = false) => {
151152
if (dryRun) {
152153
console.log("-------------------------")
153154
console.log(commitMessage)
154155
console.log("-------------------------")
156+
} else if (duet) {
157+
execSync(`git duet-commit -m "${commitMessage}"`)
155158
} else {
156159
execSync(`git commit -m "${commitMessage}"`)
157160
}
158161
}
159162

160163
const main = (program, template, definitions, terms) => {
161164
const commitMessage = replaceTerms(program, template, definitions, terms)
162-
gitCommit(commitMessage.trim(), program.dryRun)
165+
gitCommit(commitMessage.trim(), program.duet, program.dryRun)
163166
}
164167

165168
//

0 commit comments

Comments
 (0)