Class: ConfCtl::Swpins::ChangeSet

Inherits:
Object
  • Object
show all
Defined in:
lib/confctl/swpins/change_set.rb

Defined Under Namespace

Classes: SpecOwner, SpecSet

Instance Method Summary collapse

Constructor Details

#initializeChangeSet

Returns a new instance of ChangeSet.



33
34
35
# File 'lib/confctl/swpins/change_set.rb', line 33

def initialize
  @owners = {}
end

Instance Method Details

#add(owner, spec) ⇒ Object

Parameters:



39
40
41
42
43
44
45
46
47
# File 'lib/confctl/swpins/change_set.rb', line 39

def add(owner, spec)
  @owners[owner] ||= []
  @owners[owner] << SpecSet.new(
    spec:,
    original_version: spec.valid? ? spec.version : nil,
    original_info: spec.valid? ? spec.info : nil
  )
  nil
end

#commit(type: :upgrade, changelog: false) ⇒ Object

Parameters:

  • type (:upgrade, :downgrade) (defaults to: :upgrade)
  • changelog (Boolean) (defaults to: false)


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

def commit(type: :upgrade, changelog: false)
  return if @owners.empty?

  ret = Kernel.system(
    'git',
    'commit',
    '-e',
    '-m', build_message(type, changelog),
    *changed_files
  )

  return if ret

  raise 'git commit exited with non-zero status code'
end