question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Run hook only if specific files has changed

See original GitHub issue

Hi, 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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
asottilecommented, Nov 30, 2021

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

1reaction
asottilecommented, Dec 3, 2021

try filling out the issue template, I can’t see your screen to understand where you’re going wrong

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found