revision 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d52b5583cb4ae656d41eb5389156de53000fedd75980cda75e21b97ff9a81a4f
4
- data.tar.gz: f2c5381a07f171f9d5bb45f09edf6465bc1a8666adaf293db0820a58282c2a49
3
+ metadata.gz: adcdc2d0e9d54552cb574a4abcf0f4c305ee1b4679de002a0a6b237ece5b2844
4
+ data.tar.gz: f316d48ab9d95456707bd10264d99a082b4d3ebbf0c9b2056723af0df3b6e363
5
5
  SHA512:
6
- metadata.gz: 341c226a4413b6e43b49ecd073ee87431c989d209f27f3bbf5d2c0e871d9998c2fbb8f67d7cb2161260d379e74695694be0a055b9f23b8975f0d172da952ef44
7
- data.tar.gz: f0aa801651600773e6764a51c88316920276d6ee9bf38d03351fcc534835a7d0bc167e97dcf5b8ac4c78b58234d04072f3dfe968007f8cef08693e501c42c69b
6
+ metadata.gz: 236bea8efec06c900852eef6d30bbe544dc50cc9d5a3e27e68de45847f32cfeada7f1c22ddbcdff3245cc1dda2716ac20b827cf83d67d3fb914c65d339bf6187
7
+ data.tar.gz: 5a18f6d7d2668214c7b1c71fe4d3d25bfbfa78de9c66c3d722bc2cb85cf5097a85adb168a20e4a59b94ae60943dcbb3625417402d51107bf9d52a14397e60cf8
data/lib/revision/cli.rb CHANGED
@@ -119,8 +119,26 @@ module Revision
119
119
  def do_increment(type)
120
120
  r = select_one
121
121
  increment_method = "#{type}_increment!"
122
- say "Incrementing #{r.revision} to #{r.revision.public_send(increment_method)}"
123
- options[:dryrun] ? r.revision.write_to_file : r.revision.write!
122
+ say "Incrementing #{r.revision} to #{r.revision.public_send(increment_method)} (#{r.revision.src})"
123
+ if options[:dryrun]
124
+ r.revision.write(r.revision.src + ".new")
125
+ r.secondary_revisions.each do |s|
126
+ say "Propagating revision update to #{s.src}"
127
+ s.major = r.revision.major
128
+ s.minor = r.revision.minor
129
+ s.patch = r.revision.patch
130
+ s.write(s.src + ".new")
131
+ end
132
+ else
133
+ r.revision.write!
134
+ r.secondary_revisions.each do |s|
135
+ say "Propagating revision update to #{s.src}"
136
+ s.major = r.revision.major
137
+ s.minor = r.revision.minor
138
+ s.patch = r.revision.patch
139
+ s.write!
140
+ end
141
+ end
124
142
  say ''
125
143
  say "The automatic commit / tag step assumes you're only checking in changes to existing files"
126
144
  say "You can answer 'n' at the prompt and use 'revision tag' to generate a commit with the latest changelog entry and an associated tag after manually adding any new files to the repo"
data/lib/revision/info.rb CHANGED
@@ -15,10 +15,11 @@ class Revision::Info
15
15
  attr_accessor :regex
16
16
  attr_accessor :comment_prefix
17
17
 
18
- def initialize(file, regex: nil, comment_prefix: nil)
18
+ def initialize(file, regex: nil, comment_prefix: nil, embed_changelog: true)
19
19
  @src=file
20
20
  @regex = regex.nil? ? DEFAULT_REGEX : /#{regex}/
21
21
  @comment_prefix = comment_prefix || DEFAULT_COMMENT_PREFIX
22
+ @embed_changelog = embed_changelog
22
23
  matched = false
23
24
  File.open(@src).each_line do |line|
24
25
  if line =~ @regex
@@ -65,15 +66,16 @@ class Revision::Info
65
66
  ref_info = self.class.new(@src, regex: @regex)
66
67
  raise 'No revision identifiers incremented' if ref_info.to_s == self.to_s
67
68
 
68
- entry = get_changelog_entry
69
69
 
70
70
  text = File.read(@src)
71
71
  text.gsub!(@regex) { |match| "#{$~[:prefix]}#{@major}#{$~[:sep1]}#{@minor}#{$~[:sep2]}#{@patch}#{$~[:postfix]}" }
72
72
 
73
- #Insert start/end tags if not present
74
- text += new_changelog_placeholder unless text.match(CHANGELOG_START)
75
-
76
- text.gsub!(CHANGELOG_START) { |match| [match, format_changelog_entry(entry)].join("\n") }
73
+ if @embed_changelog
74
+ entry = get_changelog_entry
75
+ #Insert start/end tags if not present
76
+ text += new_changelog_placeholder unless text.match(CHANGELOG_START)
77
+ text.gsub!(CHANGELOG_START) { |match| [match, format_changelog_entry(entry)].join("\n") }
78
+ end
77
79
 
78
80
  File.open(output_file_name, 'w') { |f| f.write(text) }
79
81
  end
@@ -17,7 +17,7 @@ module Revision
17
17
 
18
18
  REVISION_PLACEHOLDER = /<REV>|<VER>/
19
19
 
20
- attr_reader :root, :id, :revision, :build_steps, :artefacts, :git_tag_prefix
20
+ attr_reader :root, :id, :revision, :build_steps, :artefacts, :git_tag_prefix, :secondary_revisions
21
21
 
22
22
  # Load a file in yaml format containing one or more releasable definitions
23
23
  # @param root [String] An optional root directory argument
@@ -53,12 +53,17 @@ module Revision
53
53
  # @git_repo
54
54
  # end
55
55
 
56
+ def _build_revision_info(definition, embed_changelog: true)
57
+ Info.new(File.join(@root,definition[:src]), regex: definition[:regex], comment_prefix: definition[:comment_prefix], embed_changelog: embed_changelog)
58
+ end
59
+
56
60
  def initialize(root: nil, config: {})
57
61
 
58
62
  root ||= Dir.getwd
59
63
  @root = Pathname.new(root).realpath
60
64
  @id = config[:id] || File.basename(@root)
61
- @revision = Info.new(File.join(@root,config[:revision][:src]), regex: config[:revision][:regex], comment_prefix: config[:revision][:comment_prefix])
65
+ @revision = _build_revision_info(config[:revision], embed_changelog: true)
66
+ @secondary_revisions = config[:secondary_revisions].nil? ? [] : config[:secondary_revisions].map { |r| _build_revision_info(r, embed_changelog:false)}
62
67
  @git_tag_prefix = config[:revision][:git_tag_prefix].nil? ? 'v' : "#{config[:revision][:git_tag_prefix]}_v"
63
68
  # Legacy definition syntax compatibility
64
69
  @build_def = config[:build] ? config[:build] : { environment: { variables: {}}, steps: config[:build_steps]}
@@ -1,10 +1,13 @@
1
1
  # Defines the revision ID for the revision gem
2
2
  module Revision
3
- VERSION = "1.3.1"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
 
6
6
  # <BEGIN CHANGELOG>
7
7
  #
8
+ # Version 1.4.0 (10 Jun 2019)
9
+ # - Now allow the definition of one or more 'secondary_revisions', where a revision ID can be updated with or without an embedded changelog
10
+ #
8
11
  # Version 1.3.1 (20 May 2019)
9
12
  # - Corrected bug when deploying changelog:w
10
13
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revision
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cormac Cannon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor