gitlint is showing all files as changed in github CI
See original GitHub issueGitlint is incorrectly listing all files as changed in CI, not only those that have changed: https://github.com/jorisroovers/gitlint/actions/runs/3014300199/jobs/4935936697#step:14:104
Is this perhaps due to a misuse of refspec? Should we be passing a -1
argument like we do with log
?
Issue Analytics
- State:
- Created a year ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Issues · jorisroovers/gitlint - GitHub
Linting for your git commit messages. Contribute to jorisroovers/gitlint development by creating an account on GitHub.
Read more >Git status shows files as changed even though contents are ...
I have resolved this problem using following steps. Remove every file from Git's index. git rm --cached -r . Rewrite the Git index...
Read more >Configuration - Gitlint - Joris Roovers
Configuration. Gitlint can be configured through different means. The .gitlint file. You can modify gitlint's behavior by adding a .gitlint file to your...
Read more >File: README — Documentation for git-lint (2.1.0)
cd example git checkout -b test touch text.txt git add --all . git commit ... As shown above, the --commit-message option accepts a...
Read more >Supported hooks - pre-commit
php-lint-all - Check PHP Syntax on ALL PHP staged files with user friendly ... gitlint - Checks your git commit messages for style....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I realize I didn’t mention earlier that there’s really 2 parts to this.
Initial Commits and the git diff-tree --root flag
An important detail worth repeating is that git itself doesn’t consider files of the initial commit as “changed files” when you do
git diff-tree
, i.e. for the initial commit, git won’t show you the added files unless you specifically tell it to with the--root
flag.I had added the
--root
flag to thegit diff-tree
command that gitlint calls to deal with this, but hadn’t consider the shallow clone scenario.Since I’ve now discovered that it’s not possible for gitlint to (easily + accurately) determine whether a commit is root commit, I believe gitlint should align with git’s behavior and not show files for initial/root commits unless you explicitly tell it to, with a config option like:
You don’t actually have to use a
.gitlint
file for this, rather you can use the-c
commandline flag to specify the same:gitlint -c general.diff-tree-root=True
. Gitlint will still read the.gitlint
file, but apply this config on top.By using this construct, you can have an if/else statement in CI that deals with the initial commit separately if you really want it to. I think most users won’t actually care for the initial commit. We could documenting and/or provide templates on how to do this in various CI systems.
Fetch depth
However, this
diff-tree-root
option still doesn’t correctly solve thefetch-depth=1
challenge in CI, it just provides and all-or-nothing alternative to it. Settingdiff-tree-root=True
will end up showing all files, settingdiff-tree-root=False
will show none if fetch-depth is only 1.The only way to resolve this AFAICT, is to increase the fetch-depth, which is CI specific. I don’t want to include CI specific customizations in gitlint itself, but perhaps we can also make this better using documentation and/or templates.
To reproduce this locally:
I get that now thanks to your explanation, so thanks!