class Danger::DangerfileGitPlugin

Handles interacting with git inside a Dangerfile. Providing access to files that have changed, and useful statistics. Also provides access to the commits in the form of [Git::Log](github.com/schacon/ruby-git/blob/master/lib/git/log.rb) objects.

@example Do something to all new and edited markdown files

markdowns = (git.added_files + git.modified_files)
do_something markdowns.select{ |file| file.end_with? "md" }

@example Don’t allow a file to be deleted

deleted = git.deleted_files.include? "my/favourite.file"
failure "Don't delete my precious" if deleted

@example Fail really big diffs

failure "We cannot handle the scale of this PR" if git.lines_of_code > 50_000

@example Warn when there are merge commits in the diff

if git.commits.any? { |c| c.parents.count > 1 }
  warn 'Please rebase to get rid of the merge commits in this PR'
end

@example Warn when somebody tries to add nokogiri to the project

diff = git.diff_for_file("Gemfile.lock")
if diff && diff.patch =~ "nokogiri"
  warn 'Please do not add nokogiri to the project. Thank you.'
end

@see danger/danger @tags core, git