@@ -67,16 +67,53 @@ As part of `npm test`
6767 }
6868` ` `
6969
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+
7097#### Travis
7198
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+
72107```yml
73108# Force full git checkout
74109before_install: git fetch --unshallow
75110
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
78113```
79114
115+ > \[1\]: See [scripts/lint:commit.sh](./scripts/lint:commit.sh) for reference
116+
80117### API
81118
82119The programming interface does not read configuration by default,
@@ -208,7 +245,7 @@ Perform `git fetch --shallow` before linting.
208245Most likely you are reading this because you where presented with an error message:
209246
210247```
211- ' Could not get git history from shallow clone.
248+ ' Could not get git history from shallow clone.
212249 Use git fetch --shallow before linting.
213250 Original issue: https://git.io/vyKMq\n Refer to https://git.io/vyKMv for details.'
214251```
@@ -217,7 +254,7 @@ Most likely you are reading this because you where presented with an error messa
217254
218255git supports checking out `shallow` clones of a repository to save bandwith in times.
219256These 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.
221258To ensure linting works every time you should convert a shallow git repo to a complete one.
222259Use `git fetch --shallow` to do so.
223260
@@ -226,7 +263,7 @@ Use `git fetch --shallow` to do so.
226263Ensure full git checkouts on TravisCI, add to `.travis.yml`:
227264
228265```yml
229- before_install:
266+ before_install:
230267 - git fetch --unshallow
231268```
232269
0 commit comments