Class: VCPkg::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vcpkg_pipeline/extension/vcpkg_vpl.rb

Overview

VCPkg::Base

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Base

Returns a new instance of Base.



25
26
27
28
29
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 25

def initialize(path)
  @path = path

  @git = Git.open(@path)
end

Instance Attribute Details

#gitObject

Returns the value of attribute git.



23
24
25
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 23

def git
  @git
end

#pathObject

Returns the value of attribute path.



23
24
25
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 23

def path
  @path
end

Instance Method Details

#add_version(vcport, commit_message) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 43

def add_version(vcport, commit_message)
  name = vcport.vcpkg.name

  `vcpkg x-add-version #{name} --vcpkg-root=#{@path}`
  @git.add('.')
  @git.commit(commit_message, amend: true)
end

#copy_port(vcport, commit_message) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 35

def copy_port(vcport, commit_message)
  name = vcport.vcpkg.name

  `cp #{vcport.port_path}/* #{ports}/#{name}`
  @git.add('.')
  @git.commit(commit_message)
end

#portsObject



31
32
33
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 31

def ports
  "#{@path}/ports"
end

#publish(vcport) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vcpkg_pipeline/extension/vcpkg_vpl.rb', line 51

def publish(vcport)
  name = vcport.vcpkg.name

  @git.quick_stash('保存之前的修改')

  port_exist = File.directory? "#{@path}/ports/#{name}"
  `mkdir -p #{@path}/ports/#{name}` unless port_exist

  commit_message = "[#{name}] #{port_exist ? 'Update' : 'Add'} #{vcport.vcpkg.version}"

  copy_port(vcport, commit_message)
  add_version(vcport, commit_message)

  @git.quick_push
end