Giter VIP home page Giter VIP logo

Comments (2)

jorisroovers avatar jorisroovers commented on May 10, 2024

So I looked into this a bit more and think gitlint actually supports this out of the box already, perhaps with a small caveat.

See http://jorisroovers.github.io/gitlint/#linting-a-range-of-commits

You can use gitlint to lint a single sha like so:

SHA="f0c4acf161a23f37c8af8985d281254822280227"
gitlint --commits ${SHA}^...${SHA}
# I've noticed that there's a mistake in the docs, since it says you can just do 'gitlint --commits ${SHA}' to lint a single commit.
# In reality, that will lint all commits in the repo that occured before (and incl) that particular commit (this is inline with git's refspec defintion).
# I'll fix the docs on that.

This will also work if you want to specific a range of commits (which I'm thinking is what you'd really want):

gitlint --commits ${START_SHA}...${END_SHA}

The caveat is that if you want to lint a specific set of non-consecutive shas, you'll have to write a for loop:

for sha in f0c4acf161a23f37c8af8985d281254822280227 03eec2042d97a4414b45e0f5f7e67fa85ce9f80b 2a05f1b12bcc830c5d2da93d180230e1f74922dd; do
   gitlint --debug --commits ${sha}^...${sha}
done

I've thought before about adding support for comma-separated sha lists to gitlint, but haven't gotten to it yet.
That would work like so:

gitlint --commits <sha1>,<sha2>,<sha3>

As an FYI, if there's still a case for adding in PR #61, then it will need some changes - in particular wrt the tests, these should be added to the other integration tests in the qa directory and not as a special case in ./run_tests.sh.

I was planning on quickly doing that myself, but than figured out that this PR is likely not needed as per the above. I pushed the work I already did to the issues/61 branch for future reference.

Hope this helps!

from gitlint.

gaul avatar gaul commented on May 10, 2024

The caveat is that if you want to lint a specific set of non-consecutive shas, you'll have to write a for loop:

The only difference is whether the loop is inside gitlint or the in pre-push script, as the small addition to cli.py demonstrates. Linting on pre-push is the primary use case for my projects and something I expect out of box. For example I run all my compilation and style checks in this manner. However, if you do not want to directly support this use case please close this issue and the related pull request.

from gitlint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.