Class: LearnTest::Git::Wip::Reference

Inherits:
Branch
  • Object
show all
Defined in:
lib/learn_test/git/wip/reference.rb

Constant Summary collapse

PREFIX =
'refs/wip/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Branch

#last_revision, #to_s

Constructor Details

#initialize(base:, name:) ⇒ Reference

Returns a new instance of Reference.



13
14
15
16
17
18
19
20
21
22
# File 'lib/learn_test/git/wip/reference.rb', line 13

def initialize(base:, name:)
  dir = File.join(base.repo.path, PREFIX)
  file = File.join(dir, name)
  sha = base.log(1)[0].sha

  FileUtils.mkdir_p(dir, { mode: 0755 }) unless Dir.exist?(dir)
  File.open(file, 'w+') { |f| f.puts sha } unless File.exist?(file)

  super(base: base, name: "#{PREFIX}#{name}")
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



9
10
11
# File 'lib/learn_test/git/wip/reference.rb', line 9

def parent
  @parent
end