class Syntaxer::Git
Public Class Methods
new(repo_path)
click to toggle source
# File lib/syntaxer/repository.rb, line 21 def initialize(repo_path) @repository = ::Git.open(File.expand_path(repo_path)) rescue ArgumentError => ex raise GitRepositoryError, "The path you specified is not a git repository: '#{File.expand_path(repo_path)}'" end
Public Instance Methods
added_files()
click to toggle source
Returns list of files what have been added
@return [Array]
# File lib/syntaxer/repository.rb, line 41 def added_files @repository.chdir do @added ||= @repository.status.added.to_a.map(&:first) end end
changed_and_added_files()
click to toggle source
Aggregates added and changed files in one array
@return [Array]
# File lib/syntaxer/repository.rb, line 51 def changed_and_added_files check_repo changed_files + added_files end
changed_files()
click to toggle source
Returns list of files what have been changed
@return [Array]
# File lib/syntaxer/repository.rb, line 31 def changed_files @repository.chdir do @changed ||= @repository.status.changed.to_a.map(&:first) end end
Private Instance Methods
check_repo()
click to toggle source
# File lib/syntaxer/repository.rb, line 57 def check_repo @logs = @repository.log @logs.first rescue ::Git::GitExecuteError => e puts "We can not find new or changed files. Log history is empty.\nPlease make first commit.".color(:red) raise e exit 1 end