Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "conditional ignoring of changes" #828

Open
e2 opened this issue Apr 30, 2016 · 1 comment
Open

Implement "conditional ignoring of changes" #828

e2 opened this issue Apr 30, 2016 · 1 comment
Labels
✨ Feature Adds a new feature

Comments

@e2
Copy link
Contributor

e2 commented Apr 30, 2016

Sometimes there are situations where responding to changes doesn't make sense, e.g. while switching git branches.

In this case, we still want to monitor changes (instead of pausing), but we don't want to run any Guard plugins. E.g. we don't want to run any changes unless the branch is 'master'.

Implementation: not sure.

Alternative 1: wrapping every watch block to return nil if a given condition evaluates to true.

Alternative 2: wrapping everything in a group with halt_on_fail and having the first task "fail" if a condition is true.

Alternative 3: monkey-patching Guard to not run tasks when a condition is true

@rymai rymai added ✨ Feature Adds a new feature and removed feature request labels Oct 31, 2019
@dp28
Copy link

dp28 commented Aug 13, 2020

I've also run into this problem, specifically trying to prevent Guard running any plugins when switching git branches. I've added a couple of potential solutions to this gem: https://github.com/dp28/guard-git.

One of the solutions is a custom matcher that essentially returns nil unless the files that triggered the change have been modified since the last commit.

The other solution monkey-patches Guard's watch method to automatically apply this custom matcher.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Feature Adds a new feature
Projects
None yet
Development

No branches or pull requests

3 participants