Skip to content

Commit

Permalink
docs: updates README
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Jan 20, 2022
1 parent 853d9ef commit f58f36f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 24 deletions.
13 changes: 12 additions & 1 deletion .husky.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
# version-file which will write or read current semver
version-file = "internal/version/version"

# hook scripts
[hooks]

# after version calc,
# with use the {{ .Version }} to upgrade other files.
post-version = [
"sed -i -e 's/\"version\": \"[^\"]*\"/\"version\": \"{{ .Version }}\"/g' testdata/pacakge.json",
"sed -i -e 's/version: [^\\n]*/version: {{ .Version }}/g' testdata/pubspec.yaml"
]

# git hook pre commit
pre-commit = [
"golangci-lint run",
"husky lint-staged",
]

# git hook commit msg
commit-msg = [
"husky lint-commit",
]

# list staged files do some pre-process and git add
[lint-staged]
"*.go" = [
"goimports -l -w",
"gofmt -l -w",
]

# commit msg rule default support conventional commits
[lint-commit]
email = "^([email protected]|[email protected]|[email protected])$"
# could check if this exists
# email = "^([email protected]|[email protected])$"
# optional custom types check regex
# types = "^(feat|fix|build|chore|ci|docs|perf|refactor|revert|style|test)$"
# optional header check regex
# header = "^(?P<type>\w+)(\((?P<scope>[\w/.-]+)\))?(?P<breaking>!)?:( +)?(?P<header>.+)"
66 changes: 43 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,50 @@ install git hooks
husky init
```

## Configuration `.husky.yaml`

```yaml
hooks:
# hook scripts
pre-commit:
- golangci-lint run
- husky lint-staged
commit-msg:
- husky lint-commit

## Configuration `.husky.toml`

`.husky.yaml` supported too.

```toml
# version-file which will write or read current semver
version-file = "internal/version/version"

# hook scripts
[hooks]

# after version calc,
# with use the {{ .Version }} to upgrade other files.
post-version = [
"sed -i -e 's/\"version\": \"[^\"]*\"/\"version\": \"{{ .Version }}\"/g' testdata/pacakge.json",
"sed -i -e 's/version: [^\\n]*/version: {{ .Version }}/g' testdata/pubspec.yaml"
]

# git hook pre commit
pre-commit = [
"golangci-lint run",
"husky lint-staged",
]

# git hook commit msg
commit-msg = [
"husky lint-commit",
]

# list staged files do some pre-process and git add
lint-staged:
"*.go":
- gofmt -l -w

# commit msg rule only support conventionalcommits
lint-commit:
# could check if this exists
email: "^([email protected]|[email protected])$"
# optional custom types check regex
types: "^(feat|fix|build|chore|ci|docs|perf|refactor|revert|style|test)$"
# optional header check regex
header: "^(?P<type>\w+)(\((?P<scope>[\w/.-]+)\))?(?P<breaking>!)?:( +)?(?P<header>.+)"
[lint-staged]
"*.go" = [
"goimports -l -w",
"gofmt -l -w",
]

# commit msg rule default support conventional commits
[lint-commit]
# could check if this exists
# email = "^([email protected]|[email protected])$"
# optional custom types check regex
# types = "^(feat|fix|build|chore|ci|docs|perf|refactor|revert|style|test)$"
# optional header check regex
# header = "^(?P<type>\w+)(\((?P<scope>[\w/.-]+)\))?(?P<breaking>!)?:( +)?(?P<header>.+)"
```

Commit msg rule follow <https://www.conventionalcommits.org/en/v1.0.0/>
Expand Down

0 comments on commit f58f36f

Please sign in to comment.