Skip to content

Instantly share code, notes, and snippets.

@michaelmontano
Created January 19, 2011 01:26
Show Gist options
  • Save michaelmontano/785511 to your computer and use it in GitHub Desktop.
Save michaelmontano/785511 to your computer and use it in GitHub Desktop.
class ChangeInPathsTrigger
def initialize(triggered_project, triggered_paths)
@triggered_project = triggered_project
@triggered_paths = triggered_paths
end
def build_necessary?(reasons)
p = @triggered_project
p.notify :polling_source_control
p.source_control.execute_in_local_copy(["git", "fetch"], {})
@triggered_paths.each do |path|
p.source_control.execute_in_local_copy(["git", "diff", "origin/master", "--", path], {}) do |io|
lines = io.readlines
if not lines.empty?
p.notify :new_revisions_detected, []
return true
end
end
end
return false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment