Comments (2)
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.
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)
- [QUESTION] Is it possible to check for the total commit message length instead of just line length? HOT 2
- Ability to define more than one extra path HOT 2
- Ability to have user-defined rules disabled by default HOT 2
- gitlint raises an exception if run without --staged and with an ignore-by-author-name configuration HOT 3
- Support for per-user configuration files and configuration inheritance HOT 9
- Ignore stdin by default in CI HOT 7
- Feature request: generate a junit or sarif report HOT 4
- Allow several --extra-path HOT 1
- v0.19.0dev tag should not be on the default branch HOT 7
- gitlint and gitlint-core v0.19.0 fail to build from sdist HOT 13
- 0.20.0 Release Plan
- Enable support for git archive installs HOT 7
- Consider adopting pypi-publish GHA instead of hatch publish
- Adopt GHA environments HOT 1
- Refactor GHA pipelines for improved security HOT 4
- Investigate smoke testing of sdist package for downstream packaging HOT 3
- Commit message with a hash sign at the start is not detected HOT 5
- Full workflow example for fixing a previously rejected commit message HOT 2
- installing hook on pre-commit fails with newest virtualenv (>20.24.5) present HOT 15
- Forever violations even after being edited HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gitlint.