Skip to content

Commit 98accb5

Browse files
authored
WIP(doc): update docs (#16)
1 parent 9dc539a commit 98accb5

File tree

2 files changed

+36
-30
lines changed

2 files changed

+36
-30
lines changed

README.md

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,6 @@ The [survey](https://github.com/AlecAivazis/survey) project is no longer maintai
66

77
## Getting Started
88

9-
installation with source code:
10-
11-
```
12-
$ make && make install
13-
```
14-
15-
or
16-
17-
```
18-
$ make && ./commitizen-go install
19-
```
20-
21-
commit with commitizen:
22-
23-
```
24-
$ git cz
25-
```
26-
27-
## Usage
28-
299
```
3010
Command line utility to standardize git commit messages.
3111
@@ -35,28 +15,50 @@ Usage:
3515
3616
Available Commands:
3717
init Initialize this tool to git-core as git-cz.
38-
load Load templates.
3918
help Help about any command
4019
4120
Flags:
42-
-s, --signoff Add a Signed-off-by trailer by the committer at the end of the commit log message.
43-
-a, --add Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
21+
-s, --signoff add a Signed-off-by trailer by the committer at the end of the commit log message.
22+
-a, --add tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.
23+
--dry-run you can use the --dry-run flag to preview the message that would be committed, without really submitting it.
4424
-h, --help help for commitizen
4525
4626
Use "commitizen [command] --help" for more information about a command.
4727
```
4828

49-
## Configure
29+
commit with commitizen:
30+
31+
```
32+
$ git cz
33+
```
34+
35+
## Installing commitizen
36+
37+
### From the Binary Releases
38+
39+
### From Source
5040

51-
You can set configuration file that .git-czrc at repository root or home directory. (You can also add the extension to file, like .git-czrc.yaml) The configure file that located in repository root have a priority over the one in home directory. The format is the same as the defaultConfig string in the file [commit/defaultConfig.go]().
41+
You must have a working Go environment:
5242

53-
Type item like that:
43+
```
44+
$ git clone https://github.com/shipengqi/commitizen.git
45+
$ cd commitizen
46+
$ make && make install
47+
```
48+
49+
Or:
5450

5551
```
56-
package render
52+
$ make && ./commitizen-go install
53+
```
54+
55+
## Configuration
56+
57+
You can set configuration file that `.git-czrc` at repository root or home directory. The configuration file that located in repository root have a priority over the one in home directory. The format is the same as the following:
5758

58-
const DefaultCommitTemplate = `---
59-
name: default
59+
```yaml
60+
name: my-default
61+
default: true # (optional) If true, this template will be used as the default template, note that there can only be one default template
6062
items:
6163
- name: type
6264
desc: "Select the type of change that you're committing:"
@@ -98,7 +100,7 @@ items:
98100
format: "{{.type}}{{with .scope}}({{.}}){{end}}: {{.subject}}{{with .body}}\n\n{{.}}{{end}}{{with .footer}}\n\n{{.}}{{end}}"`
99101
```
100102

101-
Template like that:
103+
Commit message `format`:
102104

103105
```
104106
format: "{{.type}}{{with .scope}}({{.}}){{end}}: {{.subject}}{{with .body}}\n\n{{.}}{{end}}{{with .footer}}\n\n{{.}}{{end}}"

internal/config/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func (c *Config) Initialize() error {
4646
}
4747
for _, v := range tmpls {
4848
if v.Default {
49+
if c.defaultTmpl != nil {
50+
// the default template already exists
51+
return errors.New("only one default template is permitted")
52+
}
4953
c.defaultTmpl = v
5054
continue
5155
}

0 commit comments

Comments
 (0)