Skip to content

Commit f56157e

Browse files
authored
Add branch option documentation
1 parent 057e0dc commit f56157e

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ And a `COMMITHASH` such as:
4040
7c16d8b1abeced419c14eb9908baeb4229ac0542
4141
```
4242

43+
And with the branch option enabled a `BRANCH` such as:
44+
45+
```
46+
master
47+
```
48+
4349
## Configuration
4450

4551
The plugin requires no configuration by default, but it is possible to configure it to support custom git workflows.
@@ -60,6 +66,22 @@ module.exports = {
6066
}
6167
```
6268

69+
### `branch: false`
70+
71+
If you need branch name support, you may turn on `branch` option in this way:
72+
73+
```javascript
74+
var GitRevisionPlugin = require('git-revision-webpack-plugin')
75+
76+
module.exports = {
77+
plugins: [
78+
new GitRevisionPlugin({
79+
branch: true
80+
})
81+
]
82+
}
83+
```
84+
6385
### `commithashCommand: 'rev-parse HEAD'`
6486

6587
To change the default `git` command used to read the value of `COMMITHASH`:
@@ -92,12 +114,29 @@ module.exports = {
92114
}
93115
```
94116

117+
### `branchCommand: 'rev-parse --abbrev-ref HEAD'`
118+
119+
To change the default `git` command used to read the value of `BRANCH`:
120+
121+
```javascript
122+
var GitRevisionPlugin = require('git-revision-webpack-plugin')
123+
124+
module.exports = {
125+
plugins: [
126+
new GitRevisionPlugin({
127+
branchCommand: 'git rev-parse --symbolic-full-name HEAD'
128+
})
129+
]
130+
}
131+
```
132+
95133
## Path Substitutions
96134

97135
It is also possible to use two [path substituitions](http://webpack.github.io/docs/configuration.html#output-filename) on build to get either the revision or version as part of output paths.
98136

99137
- `[git-revision-version]`
100138
- `[git-revision-hash]`
139+
- `[git-revision-branch]` (only with the branch option enabled)
101140

102141
Example:
103142

@@ -112,7 +151,7 @@ module.exports = {
112151

113152
## Plugin API
114153

115-
The `VERSION` and `COMMITHASH` are also exposed through a public API.
154+
The `VERSION`, `COMMITHASH` and `BRANCH` are also exposed through a public API.
116155

117156
Example using the [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin):
118157

@@ -124,6 +163,7 @@ module.exports = {
124163
new DefinePlugin({
125164
'VERSION': JSON.stringify(gitRevisionPlugin.version()),
126165
'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
166+
'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
127167
})
128168
]
129169
}

0 commit comments

Comments
 (0)