Class: Vendorificator::Segment::Vendor

Inherits:
Vendorificator::Segment show all
Defined in:
lib/vendorificator/segment/vendor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Vendorificator::Segment

#fast_forward, #head, #included_in_list?, #merged_notes, #merged_version, #pushable_refs, #run!, #status, #to_s, #updatable?, #work_dir

Constructor Details

#initialize(options) ⇒ Vendor

Returns a new instance of Vendor.



7
8
9
10
11
# File 'lib/vendorificator/segment/vendor.rb', line 7

def initialize(options)
  @vendor = options.delete(:vendor)
  @overlay = options.delete(:overlay)
  super
end

Instance Attribute Details

#overlayObject (readonly)

Returns the value of attribute overlay.



5
6
7
# File 'lib/vendorificator/segment/vendor.rb', line 5

def overlay
  @overlay
end

#vendorObject (readonly)

Returns the value of attribute vendor.



5
6
7
# File 'lib/vendorificator/segment/vendor.rb', line 5

def vendor
  @vendor
end

Instance Method Details

#branch_nameObject



25
26
27
28
29
30
31
# File 'lib/vendorificator/segment/vendor.rb', line 25

def branch_name
  if overlay
    _join overlay.branch_name, group, name
  else
    super
  end
end

#compute_dependencies!Object



33
34
35
# File 'lib/vendorificator/segment/vendor.rb', line 33

def compute_dependencies!
  @vendor.compute_dependencies!
end

#conjure(options = {}) ⇒ Object

Public: Conjures the vendor module without merging back.

options - available options: :metadata - Hash with metadata information

Returns nothing.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/vendorificator/segment/vendor.rb', line 42

def conjure(options = {})
  shell.padding += 1
  @vendor.before_conjure!
  Dir.mktmpdir "vendorificator-#{name}" do |tmpdir|
    in_branch(branch_name, clean: true) do |tmpgit|
      begin
        @git = tmpgit
        @vendor.git = tmpgit

        Dir.chdir tmpdir do
          @vendor.conjure!

          subdir = @vendor.args[:subdirectory]
          make_subdir_root subdir if subdir && !subdir.empty?
        end

        FileUtils.mkdir_p work_dir
        tmpdir_entries = (Dir.entries(tmpdir) - %w'. ..').
          map { |e| File.join(tmpdir, e) }
        FileUtils.mv tmpdir_entries, work_dir
        commit_and_annotate(options[:metadata] || {})
      ensure
        @git = nil
        @vendor.git = nil
      end
    end
  end
ensure
  shell.padding -= 1
end

#groupObject



17
18
19
# File 'lib/vendorificator/segment/vendor.rb', line 17

def group
  @vendor.group
end

#merge_back(commit = branch_name) ⇒ Object

Public: Merges back to the original branch (usually master).

commit - git ref/branch to merge, defaults to segment branch

Returns nothing.



78
79
80
81
82
# File 'lib/vendorificator/segment/vendor.rb', line 78

def merge_back(commit = branch_name)
  git.capturing.merge({no_edit: true, no_ff: true}, commit) unless config.fake_mode?
  @vendor.postprocess! if @vendor.respond_to? :postprocess!
  @vendor.compute_dependencies!
end

#nameObject



13
14
15
# File 'lib/vendorificator/segment/vendor.rb', line 13

def name
  @vendor.name
end

#versionObject



21
22
23
# File 'lib/vendorificator/segment/vendor.rb', line 21

def version
  @vendor.version
end