mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-26 18:33:03 +01:00
feat(git-commit): support optional commit body (#14169)
This commit is contained in:
1 parent
b1d468701a
commit
e333686c2a
2 files changed
+17
-5
No files matched your search
@@ -12,7 +12,7 @@ plugins=(... git-commit)
|
||||
## Syntax
|
||||
|
||||
```zsh
|
||||
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] "<message>"
|
||||
git <type> [(-s, --scope) "<scope>"] [(-a, --attention)] [(-b, --body) "<body>"] "<message>"
|
||||
```
|
||||
|
||||
Where `type` is one of the following:
|
||||
@@ -30,6 +30,9 @@ Where `type` is one of the following:
|
||||
- `test`
|
||||
- `wip`
|
||||
|
||||
The optional `-b` / `--body` becomes the commit body (a blank line after the subject), as defined by
|
||||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary).
|
||||
|
||||
> NOTE: the subcommand for `revert` type is `rev`, as otherwise it conflicts with the
|
||||
> git command of the same name. It will still generate a commit message in the format
|
||||
> `revert: <message>`
|
||||
@@ -39,6 +42,7 @@ Where `type` is one of the following:
|
||||
| Git subcommand | Command |
|
||||
| --------------------------------------------- | ---------------------------------------------------- |
|
||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||
| `git wip "work in progress"` | `git commit -m "wip: work in progress"` |
|
||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||
| `git feat -s "auth" -b "Keep session across redirects." "add login redirect"` | `git commit -m "feat(auth): add login redirect" -m "Keep session across redirects."` |
|
||||
@@ -12,11 +12,11 @@ _omz_git_commit() {
|
||||
if [[ "$_type" == rev ]]; then
|
||||
_type=revert
|
||||
fi
|
||||
local _scope _attention _message
|
||||
local _scope _attention _message _body
|
||||
while [ $# -ne 0 ]; do
|
||||
case $1 in
|
||||
-s | --scope )
|
||||
if [ -z $2 ]; then
|
||||
if [ -z "$2" ]; then
|
||||
echo >&2 "Missing scope!"
|
||||
return 1
|
||||
fi
|
||||
@@ -27,12 +27,20 @@ _omz_git_commit() {
|
||||
_attention="!"
|
||||
shift 1
|
||||
;;
|
||||
-b | --body )
|
||||
if [ -z "$2" ]; then
|
||||
echo >&2 "Missing body!"
|
||||
return 1
|
||||
fi
|
||||
_body="$2"
|
||||
shift 2
|
||||
;;
|
||||
* )
|
||||
_message="${_message} $1"
|
||||
shift 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}"
|
||||
git commit -m "${_type}${_scope:+(${_scope})}${_attention}:${_message}" ${_body:+-m} ${_body:+"$_body"}
|
||||
}
|
||||
_omz_git_commit "$@"
|
||||
Reference in new issue
Block a user