Class: GitHooks::Git

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/git_hooks/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_folder) ⇒ Git

Returns a new instance of Git.



11
12
13
# File 'lib/git_hooks/git.rb', line 11

def initialize(working_folder)
  @working_folder = working_folder
end

Instance Attribute Details

#working_folderObject (readonly)

Returns the value of attribute working_folder.



7
8
9
# File 'lib/git_hooks/git.rb', line 7

def working_folder
  @working_folder
end

Instance Method Details

#added_or_modifiedObject



19
20
21
22
23
24
# File 'lib/git_hooks/git.rb', line 19

def added_or_modified
  added = repository.status.added
  modified = repository.status.changed

  added.merge(modified).keys
end

#clean?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/git_hooks/git.rb', line 26

def clean?
  (added_files + modified_files + deleted_files + untracked_files).empty?
end

#repositoryObject



15
16
17
# File 'lib/git_hooks/git.rb', line 15

def repository
  ::Git.open(working_folder)
end