Class: GitAccess

Inherits:
Object
  • Object
show all
Includes:
Diffs, Singleton
Defined in:
lib/ducalis/git_access.rb

Constant Summary collapse

DELETED =
'deleted'.freeze
GIT_DIR =
'.git'.freeze
MODES =
{
  branch: ->(git) { git.diff('origin/master') },
  index: ->(git) { git.diff('HEAD') }
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flagObject

Returns the value of attribute flag.



18
19
20
# File 'lib/ducalis/git_access.rb', line 18

def flag
  @flag
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/ducalis/git_access.rb', line 18

def id
  @id
end

#repoObject

Returns the value of attribute repo.



18
19
20
# File 'lib/ducalis/git_access.rb', line 18

def repo
  @repo
end

Instance Method Details

#changed_filesObject



26
27
28
# File 'lib/ducalis/git_access.rb', line 26

def changed_files
  changes.map(&:path)
end

#for(path) ⇒ Object



30
31
32
33
34
# File 'lib/ducalis/git_access.rb', line 30

def for(path)
  return find(path) unless path.include?(Dir.pwd)

  find(Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s)
end

#store_pull_request!(info) ⇒ Object



20
21
22
23
24
# File 'lib/ducalis/git_access.rb', line 20

def store_pull_request!(info)
  repo, id = info
  self.repo = repo
  self.id = id
end