Run hook only if specific files has changed
See original GitHub issueHi, folks! On GitLab, we have a feature that runs a ci/cd job only if certain files changed. For example:
validate_config:
stage: build
script:
- make validate_config
only:
refs:
- master
changes:
- config.toml
I want to execute this verification whenever the developer makes a commit changing this file. Do we have a feature similar to this inside pre-commit? I couldn’t find it on the docs.
For now, the pre commit is running a make rule that checks (with git diff
) if the file has changed before running the script.
If we don’t have this feature, I would like to work on this if you all agree that is a nice to have feature.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How can I automatically be warned if a specific file changes?
The hook takes a single parameter, a status flag specifying whether or not the merge being done was a squash merge.
Read more >Execute git pre-commit hook only if files in certain directory ...
I am trying to create a bash script for a git pre-commit hook. Whenever a commit is made, ...
Read more >Make git hooks run ktlint on changed files only #1339 - GitHub
As you can see, the first command lists changed files, then only kt[s] files are selected, and finally they are piped into the...
Read more >How to use Git hooks to detect changes to a lock file and show ...
We want to run some code to alert us if the package-lock.json or yarn.lock files have changed. This happens usually when we pull...
Read more >Lint Only Files with Changes on pre-commit
... hook which runs ESLint and stylelint only on files with changes. ... our linting scripts run only on staged files; if there...
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 FreeTop 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
Top GitHub Comments
please don’t skip the issue template in the future, it helps guide the discussion and gives me information about what you’ve tried and what you’re trying to achieve and what isn’t working
I think you’ll find if you just try it or read any of the documentation you’ll have your answer pretty quickly
while I can give you a straightforward answer, that really doesn’t scale and that’s why we have documentation – please read that first and if you’re still stuck please show what you’ve tried and then I can help you
try filling out the issue template, I can’t see your screen to understand where you’re going wrong