You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/reference/hooks.md
+69-26
Original file line number
Diff line number
Diff line change
@@ -7,20 +7,29 @@ comments: true
7
7
---
8
8
# Hooks
9
9
10
-
- Each global configuration of `setup_hooks`, `pre_commit_hooks`, and `post_commit_hooks` is a list of commands run in a shell
11
-
- Explanation of the context passed into the environment
12
-
- Run in sequentially
10
+
## Hook Suites
13
11
14
-
Order of operations
12
+
A _hook suite_ is a list of _hooks_ to run sequentially. A _hook_ is either an individual shell command or an executable script.
15
13
16
-
- Run setup hooks
17
-
- Increment version
18
-
- Change files
19
-
- Run pre-commit hooks
20
-
- commit and tag
21
-
- Run post-commit hooks
14
+
There are three hook suites: _setup, pre-commit,_ and _post-commit._ During the version increment process this is the order of operations:
22
15
23
-
## Setup Hooks
16
+
1. Run _setup_ hooks
17
+
2. Increment version
18
+
3. Change files
19
+
4. Run _pre-commit_ hooks
20
+
5. Commit and tag
21
+
6. Run _post-commit_ hooks
22
+
23
+
!!! Note
24
+
25
+
Don't confuse the _pre-commit_ and _post-commit_ hook suites with Git pre- and post-commit hooks. Those hook suites are named for their adjacency to the commit and tag operation.
26
+
27
+
28
+
## Configuration
29
+
30
+
Configure each hook suite with the `setup_hooks`, `pre_commit_hooks`, or `post_commit_hooks` keys.
31
+
32
+
Each suite takes a list of strings. The strings may be individual commands:
You can make a script executable using the following steps:
58
+
59
+
1. Add a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) line to the top like `#!/bin/bash`
60
+
2. Run `chmod u+x path/to/script.sh` to set the executable bit
61
+
62
+
##Hook Environments
51
63
52
-
- The existing OS environment is available
64
+
Each hook has these environment variables set when executed.
53
65
54
-
#### Date and time fields
66
+
### Inherited environment
67
+
68
+
All environment variables set before bump-my-version was run are available.
69
+
70
+
### Date and time fields
55
71
56
72
::: field-list
57
73
@@ -61,9 +77,11 @@ git config --list
61
77
`BVHOOK_UTCNOW`
62
78
: The ISO-8601-formatted current local time in the UTC time zone.
63
79
64
-
#### Source code management fields
80
+
### Source code management fields
81
+
82
+
!!! Note
65
83
66
-
These fields will only have values if the code is in a Git or Mercurial repository.
84
+
These fields will only have values if the code is in a Git or Mercurial repository.
67
85
68
86
::: field-list
69
87
@@ -83,7 +101,7 @@ These fields will only have values if the code is in a Git or Mercurial reposito
83
101
: The current branch name, converted to lowercase, with non-alphanumeric characters removed and truncated to 20 characters. For example, `feature/MY-long_branch-name` would become `featuremylongbranchn`.
84
102
85
103
86
-
#### Version fields
104
+
###Current version fields
87
105
88
106
::: field-list
89
107
`BVHOOK_CURRENT_VERSION`
@@ -93,4 +111,29 @@ These fields will only have values if the code is in a Git or Mercurial reposito
93
111
: The current tag
94
112
95
113
`BVHOOK_CURRENT_<version component>`
96
-
: Each version component defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `current_major`, `current_minor`, and `current_patch` available.
114
+
: Each version component defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `BVHOOK_CURRENT_MAJOR`, `BVHOOK_CURRENT_MINOR`, and `BVHOOK_CURRENT_PATCH` available.
115
+
116
+
117
+
### New version fields
118
+
119
+
!!! Note
120
+
121
+
These are not available in the _setup_ hook suite.
122
+
123
+
::: field-list
124
+
`BVHOOK_NEW_VERSION`
125
+
: The new version serialized as a string
126
+
127
+
`BVHOOK_NEW_TAG`
128
+
: The new tag
129
+
130
+
`BVHOOK_NEW_<version component>`
131
+
: Each version component defined by the [version configuration parsing regular expression](configuration/global.md#parse). The default configuration would have `BVHOOK_NEW_MAJOR`, `BVHOOK_NEW_MINOR`, and `BVHOOK_NEW_PATCH` available.
132
+
133
+
## Outputs
134
+
135
+
The `stdout` and `stderr` streams are echoed to the console if you pass the `-vv` option.
136
+
137
+
## Dry-runs
138
+
139
+
Bump my version does not execute any hooks during a dry run. With the verbose output option it will state which hooks it would have run.
0 commit comments