Class: Danger::DangerfileGitPlugin
- Defined in:
- lib/danger/danger_core/plugins/dangerfile_git_plugin.rb
Overview
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.
Git Files collapse
-
#added_files ⇒ FileList<String>
Paths for files that were added during the diff.
-
#deleted_files ⇒ FileList<String>
Paths for files that were removed during the diff.
-
#modified_files ⇒ FileList<String>
Paths for files that changed during the diff.
Git Metadata collapse
-
#commits ⇒ Git::Log
The log of commits inside the diff.
-
#deletions ⇒ Fixnum
The overall lines of code removed in the diff.
-
#insertions ⇒ Fixnum
The overall lines of code added in the diff.
-
#lines_of_code ⇒ Fixnum
The overall lines of code added/removed in the diff.
Class Method Summary collapse
-
.instance_name ⇒ String
The instance name used in the Dangerfile.
Instance Method Summary collapse
-
#initialize(dangerfile) ⇒ DangerfileGitPlugin
constructor
A new instance of DangerfileGitPlugin.
Methods inherited from Plugin
all_plugins, clear_external_plugins, inherited, #method_missing
Constructor Details
#initialize(dangerfile) ⇒ DangerfileGitPlugin
Returns a new instance of DangerfileGitPlugin.
41 42 43 44 45 46 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 41 def initialize(dangerfile) super(dangerfile) raise unless dangerfile.env.scm.class == Danger::GitRepo @git = dangerfile.env.scm end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Danger::Plugin
Class Method Details
.instance_name ⇒ String
The instance name used in the Dangerfile
37 38 39 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 37 def self.instance_name "git" end |
Instance Method Details
#added_files ⇒ FileList<String>
Paths for files that were added during the diff
52 53 54 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 52 def added_files Danger::FileList.new(@git.diff.select { |diff| diff.type == "new" }.map(&:path)) end |
#commits ⇒ Git::Log
The log of commits inside the diff
100 101 102 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 100 def commits @git.log.to_a end |
#deleted_files ⇒ FileList<String>
Paths for files that were removed during the diff
60 61 62 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 60 def deleted_files Danger::FileList.new(@git.diff.select { |diff| diff.type == "deleted" }.map(&:path)) end |
#deletions ⇒ Fixnum
The overall lines of code removed in the diff
84 85 86 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 84 def deletions @git.diff.deletions end |
#insertions ⇒ Fixnum
The overall lines of code added in the diff
92 93 94 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 92 def insertions @git.diff.insertions end |
#lines_of_code ⇒ Fixnum
The overall lines of code added/removed in the diff
76 77 78 |
# File 'lib/danger/danger_core/plugins/dangerfile_git_plugin.rb', line 76 def lines_of_code @git.diff.lines end |