Skip to content

Commit

Permalink
docs: help with shallow clone troubleshooting
Browse files Browse the repository at this point in the history
* closes #7
* closes #12
  • Loading branch information
marionebl committed Apr 8, 2017
1 parent 157e14a commit 7761b8b
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 24 deletions.
98 changes: 75 additions & 23 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resolves `extends` configurations.

```shell
❯ conventional-changelog-lint --help
conventional-changelog-lint@0.1.0 - Lint commit messages against a conventional-changelog preset and ruleset
conventional-changelog-lint - Lint commit messages against a conventional-changelog preset and ruleset

[input] reads from stdin if --edit, --from, --to are omitted
--color,-c toggle formatted output, defaults to: true
Expand All @@ -42,6 +42,41 @@ resolves `extends` configurations.

```
### Recipes
#### git hook
As a `commitmsg` git-hook with ["husky"](https://git.io/JDwyQg)
```json
{
"scripts": {
"commitmsg": "conventional-changelog-lint -e"
}
}
```
#### Last commit
As part of `npm test`
```json
{
"scripts": {
"test": "conventional-changelog-lint --from=HEAD~1"
}
}
```
#### Travis
```yml
# Force full git checkout
before_install: git fetch --unshallow

# Lint all commits not in the target branch
before_script: conventional-changelog-lint --from=$TRAVIS_BRANCH to=$TRAVIS_PULL_REQUEST_BRANCH
```
### API
The programming interface does not read configuration by default,
Expand Down Expand Up @@ -77,28 +112,6 @@ const report = lint(
);
```
### Recipes
* As a `commitmsg` git-hook with ["husky"](https://git.io/JDwyQg)
```json
{
"scripts": {
"commitmsg": "conventional-changelog-lint -e"
}
}
```
* As part of `npm test`
```json
{
"scripts": {
"test": "conventional-changelog-lint --from=HEAD~1"
}
}
```
## Configuration
`conventional-changelog-lint` is configured via
Expand Down Expand Up @@ -186,6 +199,45 @@ wildcards: {
}
```
## Shallow clones
### TL;DR
Perform `git fetch --shallow` before linting.
Most likely you are reading this because you where presented with an error message:
```
'Could not get git history from shallow clone.
Use git fetch --shallow before linting.
Original issue: https://git.io/vyKMq\n Refer to https://git.io/vyKMv for details.'
```
### Explanation
git supports checking out `shallow` clones of a repository to save bandwith in times.
These limited copies do not contain a full git history. This makes `conventional-changelog-lint`
fail, especially when running on large commit ranges.
To ensure linting works every time you should convert a shallow git repo to a complete one.
Use `git fetch --shallow` to do so.
### Travis
Ensure full git checkouts on TravisCI, add to `.travis.yml`:
```yml
before_install:
- git fetch --unshallow
```
### Appveyor
Ensure full git checkouts on AppVeyor, add to `appveyor.yml`:
```yml
shallow_clone: false
```
## Supported Node.js versions
conventional-changelog-lint supports the active Node.js [LTS](https://github.com/nodejs/LTS#lts-schedule) version and higher: `>= 4`
Expand Down
8 changes: 7 additions & 1 deletion source/library/get-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {readFile} from 'mz/fs';

export default getCommitMessages;

const SHALLOW_MESSAGE = [
'Could not get git history from shallow clone.',
'Use git fetch --shallow before linting.',
'Original issue: https://git.io/vyKMq\n Refer to https://git.io/vyKMv for details.'
].join('\n');

// Get commit messages
// Object => Promise<Array<String>>
async function getCommitMessages(settings) {
Expand All @@ -16,7 +22,7 @@ async function getCommitMessages(settings) {
}

if (await isShallow()) {
throw new Error('Could not get git history from shallow clone. Original issue: https://git.io/vyKMq\n Refer to https://git.io/vyKMv for details.');
throw new Error(SHALLOW_MESSAGE);
}

return await getHistoryCommits({from, to});
Expand Down

0 comments on commit 7761b8b

Please sign in to comment.