@@ -67,16 +67,53 @@ As part of `npm test`
67
67
}
68
68
` ` `
69
69
70
+ # ### Lint all commits in Pull Request
71
+
72
+ You can lint all commits in a PR by passing all commits that
73
+ are present in ` SOURCE_BRANCH` but unavailable in ` BASE_BRANCH` :
74
+
75
+ ` ` ` sh
76
+ conventional-changelog-lint --from=BASE_BRANCH to=SOURCE_BRANCH
77
+ ` ` `
78
+
79
+ Most of the time ` BASE_BRANCH` will be ` master` for Github Flow.
80
+
81
+ This assumes ` SOURCE_BRANCH` is available on your local checkout.
82
+ This is not true by default for all PRs originating from clones of a repository.
83
+
84
+ Given you' d like to lint all commits in PR origination from branch `remote-test` on the
85
+ repository `github.com/other-name/test` targeting `master` on `github.com/your-name/test`:
86
+
87
+ ```sh
88
+ cd test # make sure CWD is in your repository
89
+ git remote add other-name https://github.com/other-name/test.git
90
+ git fetch other-name
91
+
92
+ conventional-changelog-lint --from=master --to=other-name/test
93
+ ```
94
+
95
+ See [scripts/lint:commit.sh](./scripts/lint:commit.sh#6) for an example on how to obtain `SOURCE_BRANCH` from a Github clone automatically on Travis.
96
+
70
97
#### Travis
71
98
99
+ Commit Linting on CI has to handle the following cases
100
+
101
+ * Direct commits
102
+ * Branch Pull Requests
103
+ * Fork Pull Requests
104
+
105
+ An exemplary implementation is provided as bash script working on Travis CI.
106
+
72
107
```yml
73
108
# Force full git checkout
74
109
before_install: git fetch --unshallow
75
110
76
- # Lint all commits not in the target branch
77
- before_script: conventional-changelog- lint --from= $TRAVIS_BRANCH to= $TRAVIS_PULL_REQUEST_BRANCH
111
+ script:
112
+ - ./scripts/ lint:commit.sh # [1] scripts/lint:commit.sh
78
113
```
79
114
115
+ > \[1\]: See [scripts/lint:commit.sh](./scripts/lint:commit.sh) for reference
116
+
80
117
### API
81
118
82
119
The programming interface does not read configuration by default,
@@ -208,7 +245,7 @@ Perform `git fetch --shallow` before linting.
208
245
Most likely you are reading this because you where presented with an error message:
209
246
210
247
```
211
- ' Could not get git history from shallow clone.
248
+ ' Could not get git history from shallow clone.
212
249
Use git fetch --shallow before linting.
213
250
Original issue: https://git.io/vyKMq\n Refer to https://git.io/vyKMv for details.'
214
251
```
@@ -217,7 +254,7 @@ Most likely you are reading this because you where presented with an error messa
217
254
218
255
git supports checking out `shallow` clones of a repository to save bandwith in times.
219
256
These limited copies do not contain a full git history. This makes `conventional-changelog-lint`
220
- fail, especially when running on large commit ranges.
257
+ fail, especially when running on large commit ranges.
221
258
To ensure linting works every time you should convert a shallow git repo to a complete one.
222
259
Use `git fetch --shallow` to do so.
223
260
@@ -226,7 +263,7 @@ Use `git fetch --shallow` to do so.
226
263
Ensure full git checkouts on TravisCI, add to `.travis.yml`:
227
264
228
265
```yml
229
- before_install:
266
+ before_install:
230
267
- git fetch --unshallow
231
268
```
232
269
0 commit comments