class Stefon::Surveyor::GritUtil
A class that abstracts dealing with the grit gem while respecting/knowing some restrictions, namely excluding authors
Attributes
The last commit not made by the user (sui ~ self) but by another person (xeno ~ not self / not origin). This is important to take into account when the user makes multiple commits when working on someone else's project, to ensure that diffs do not include recent changes made by the user in her last few commits
The number of commits by the user (sui ~ self / origin). This is important to take into account when the user makes multiple commits when working on someone else's project, to ensure that diffs do not include recent changes made by the user in her last few commits
Public Class Methods
sets num_sui_commits
and last_xenocommit
attributes, if the current user is the only commiter in the repo, these are set to the most recent commit, since in this case, stefon would always recommend the current user anyway. In the future, an error may be raised here
# File lib/stefon/surveyor/grit_util.rb, line 29 def initialize @repo = Grit::Repo.new find_git_repo commits = @repo.commits(GitUtil::CURRENT_BRANCH) @num_sui_commits = commits.find_index do |commit| commit.author.name != @repo.config['user.name'] end @num_sui_commits ||= 0 @last_xeno_commit = commits[@num_sui_commits] end
Public Instance Methods
# File lib/stefon/surveyor/grit_util.rb, line 47 def blame_for(filename) @repo.blame(filename, @last_xeno_commit) end
# File lib/stefon/surveyor/grit_util.rb, line 39 def find_git_repo until File.exist?('.git') fail 'Could not find a git repository!' if Dir.pwd == '/' Dir.chdir '..' end Dir.pwd end