Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to lint all commits in a PR? #12

Closed
gajus opened this issue Aug 15, 2016 · 5 comments
Closed

How to lint all commits in a PR? #12

gajus opened this issue Aug 15, 2016 · 5 comments

Comments

@gajus
Copy link

gajus commented Aug 15, 2016

I'd like to integrate conventional-changelog-lint into my CI process. I can enforce a commit convention on "client side" using Husky as per docs, but how would I enforce the convention on CI?

Assuming that a PR is a list of commits that do not exist on master, then getting those commits is simple:

git log master..$(git symbolic-ref --short HEAD)

I am not sure though whats the best way to feed them to conventional-changelog-lint. Here is what I have ended up with for now:

for sha in $(git --no-pager rev-list master..$(git symbolic-ref --short HEAD)); do git cat-file commit $sha | sed '1,/^$/d' | conventional-changelog-lint; done

The problem with the latter is that it doesn't exit if either of the validation fails.

@gajus
Copy link
Author

gajus commented Aug 15, 2016

conventional-changelog-lint --from=HEAD~$(git --no-pager rev-list master..HEAD --count)

another way to do it.

@marionebl
Copy link
Contributor

marionebl commented Aug 16, 2016

  • Add CI recipe to documentation as per @gajus
  • Consider adding a flag for pull/merge request scenarios

@honzajavorek
Copy link
Contributor

honzajavorek commented Nov 7, 2016

Why not just conventional-changelog-lint --from=master? It seems to work for me.


Answering myself: Because #7 😬

@adam-moss
Copy link
Contributor

adam-moss commented Mar 8, 2017

I've been fighting with getting this to work properly in GitLab CI with projects where we're just starting to adopt conventional-changelog. I couldn't get @gajus' example above to work for a couple of reasons and had to modify it slightly, although it feels a bit "hacky" to me:

conventional-changelog-lint --from=$( git --no-pager rev-list --no-merges origin/master..HEAD | tail -n 1 )

The first issue I had was with the git config merge.ff false option being set by some developers, locally or globally, meaning the --count figure was over-inflated, leading to a failure condition.

The 2nd issue I'm currently wrestling with is although this now gives the correct starting from commit hash as I would expect from looking at git log --oneline, the lint output is actually starting at the commit after that - @marionebl is there an oddity I'm missing here?

The CI job definition is:

conventional-changelog-lint:
    stage: compliance-tests
    script:
        - git fetch
        - ./node_modules/.bin/conventional-changelog-lint --from=$( git --no-pager rev-list --no-merges origin/master..HEAD | tail -n 1 )
    only:
        - develop

Cheers

@marionebl
Copy link
Contributor

I tested

conventional-changelog-lint --from=$TRAVIS_BRANCH --to=$TRAVIS_PULL_REQUEST_BRANCH

with success so far.

marionebl added a commit that referenced this issue Apr 8, 2017
marionebl added a commit that referenced this issue May 3, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue May 3, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue May 3, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue May 4, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue Jul 7, 2017
<a name="2.0.0"></a>
# [2.0.0](v1.1.9...v2.0.0) (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
marionebl added a commit that referenced this issue Jul 7, 2017
<a name="2.1.0"></a>
# [2.1.0](v1.1.9...v2.1.0) (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
* update to latest angular config ([b1f3606](b1f3606))

### Features

* ignore fixup and squash commit ([#17](#17)) ([f0b83d8](f0b83d8))
marionebl added a commit that referenced this issue Jul 7, 2017
* fix: warn about shallow clones

* docs: help with shallow clone troubleshooting

* closes #7
* closes #12

* test: simplify repo setup and teardown
marionebl added a commit that referenced this issue Jul 7, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue Jul 7, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
marionebl added a commit that referenced this issue Jul 7, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
* update to latest angular config ([b1f3606](b1f3606))

### Features

* ignore fixup and squash commit ([#17](#17)) ([f0b83d8](f0b83d8))
marionebl added a commit that referenced this issue Jul 10, 2017
* fix: warn about shallow clones

* docs: help with shallow clone troubleshooting

* closes #7
* closes #12

* test: simplify repo setup and teardown
marionebl added a commit that referenced this issue Jul 10, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue Jul 10, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
marionebl added a commit that referenced this issue Jul 10, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
* update to latest angular config ([b1f3606](b1f3606))

### Features

* ignore fixup and squash commit ([#17](#17)) ([f0b83d8](f0b83d8))
marionebl added a commit that referenced this issue Jul 10, 2017
* fix: warn about shallow clones

* docs: help with shallow clone troubleshooting

* closes #7
* closes #12

* test: simplify repo setup and teardown
marionebl added a commit that referenced this issue Jul 10, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue Jul 10, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
marionebl added a commit that referenced this issue Jul 10, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
* update to latest angular config ([b1f3606](b1f3606))

### Features

* ignore fixup and squash commit ([#17](#17)) ([f0b83d8](f0b83d8))
marionebl added a commit that referenced this issue Jul 11, 2017
* fix: warn about shallow clones

* docs: help with shallow clone troubleshooting

* closes #7
* closes #12

* test: simplify repo setup and teardown
marionebl added a commit that referenced this issue Jul 11, 2017
* be more explicit / guide more than #24
* closes #35
* connected to #12
marionebl added a commit that referenced this issue Jul 11, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
marionebl added a commit that referenced this issue Jul 11, 2017
… (2017-07-07)

### Bug Fixes

* prevent false positives for footer-leading-blank ([#33](#33)) ([05b4427](05b4427))
* rebuff rules ([#34](#34)) ([702a2f7](702a2f7))
* throw when detecting a shallow clone ([8c354c5](8c354c5)), closes [#7](#7) [#12](#12)
* update to latest angular config ([b1f3606](b1f3606))

### Features

* ignore fixup and squash commit ([#17](#17)) ([f0b83d8](f0b83d8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants