-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
I have created a class returning the file and the first changed line based on git. I want to launch the test of the file at only this line.
class GitModifiedMatcher
class MyMatchData
def initialize(result)
@result = result
end
def to_a
@result.values
end
def [](name)
@result[name]
end
end
def match(file)
diff = `git diff --no-ext-diff --unified=0 --exit-code -a --no-prefix #{file}`
modified_lines = diff.to_enum(:scan, /^@@ -\d+,?.* [+](\d+),?.* @@.*/).map { Regexp.last_match(1) }
MyMatchData.new(file: file, lines: modified_lines.first)
end
endSo in my Guardfile I am able to do something like this (notice the m[:file] and m[:line]) :
guard :minitest, all_on_start: false do
watch(GitModifiedMatcher.new) { |m| "#{m[:file]} --line #{m[:line]}" }
endI could not find a way to make it. Anyone can help ?
Metadata
Metadata
Assignees
Labels
No labels