puppet-blacksmith 4.0.1 → 4.1.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 +4 -4
- data/lib/puppet_blacksmith/git.rb +10 -2
- data/lib/puppet_blacksmith/modulefile.rb +7 -3
- data/lib/puppet_blacksmith/rake_tasks.rb +7 -0
- data/lib/puppet_blacksmith/version.rb +1 -1
- data/spec/puppet_blacksmith/git_spec.rb +25 -4
- data/spec/puppet_blacksmith/modulefile_spec.rb +4 -0
- metadata +4 -4
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f006f3c1be57de47df962b7a653f07c87eb61db0713ff114c47ebe8e6a669f4d
         | 
| 4 | 
            +
              data.tar.gz: 69225ae6f22e58d4f11f75f6f37922b5377df32a5b1c9231f89cd22e887d2351
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 386ad8efbc13c3f4c6c18e2a4abec43ad1d74f07e5100137f410c176d474ef37eb947323471eaac5c6d3b5ffd08023c948a3fccbe0daaa04160516f98e2c94a3
         | 
| 7 | 
            +
              data.tar.gz: 171770abef7ac2afb77957f9e82572f496149a31cf47ffdd9f411ef3721beea83dc419a564a3a1989a3c92cc7dac754095f1f092c9fb23034c59bdaa02a19356
         | 
| @@ -3,8 +3,8 @@ require 'open3' | |
| 3 3 | 
             
            module Blacksmith
         | 
| 4 4 | 
             
              class Git
         | 
| 5 5 |  | 
| 6 | 
            -
                attr_accessor :path, :tag_pattern, :tag_message_pattern, :commit_message_pattern
         | 
| 7 | 
            -
                attr_writer :tag_pattern, :tag_message_pattern, :commit_message_pattern
         | 
| 6 | 
            +
                attr_accessor :path, :tag_pattern, :tag_message_pattern, :tag_sign, :commit_message_pattern
         | 
| 7 | 
            +
                attr_writer :tag_pattern, :tag_message_pattern, :tag_sign, :commit_message_pattern
         | 
| 8 8 |  | 
| 9 9 | 
             
                # Pattern to use for tags, %s is replaced with the actual version
         | 
| 10 10 | 
             
                def commit_message_pattern
         | 
| @@ -19,6 +19,10 @@ module Blacksmith | |
| 19 19 | 
             
                  @tag_message_pattern
         | 
| 20 20 | 
             
                end
         | 
| 21 21 |  | 
| 22 | 
            +
                def tag_sign
         | 
| 23 | 
            +
                  @tag_sign
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 22 26 | 
             
                def initialize(path = ".")
         | 
| 23 27 | 
             
                  @path = File.expand_path(path)
         | 
| 24 28 | 
             
                end
         | 
| @@ -39,6 +43,10 @@ module Blacksmith | |
| 39 43 | 
             
                    tag_message = tag_message_pattern % version
         | 
| 40 44 | 
             
                    command += ["-m", tag_message]
         | 
| 41 45 | 
             
                  end
         | 
| 46 | 
            +
                  if tag_sign
         | 
| 47 | 
            +
                    raise Blacksmith::Error, 'Signed tags require messages - set tag_message_pattern' unless tag_message_pattern
         | 
| 48 | 
            +
                    command += ["-s"]
         | 
| 49 | 
            +
                  end
         | 
| 42 50 | 
             
                  exec_git command
         | 
| 43 51 | 
             
                end
         | 
| 44 52 |  | 
| @@ -28,14 +28,18 @@ module Blacksmith | |
| 28 28 | 
             
                  metadata['version']
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 | 
            -
                def  | 
| 32 | 
            -
                  new_version = increase_version(version, level)
         | 
| 31 | 
            +
                def bump_to_version!(new_version)
         | 
| 33 32 | 
             
                  text = File.read(path)
         | 
| 34 33 | 
             
                  text = replace_version(text, new_version)
         | 
| 35 | 
            -
                  File.open(path, | 
| 34 | 
            +
                  File.open(path,"w") { |file| file.puts text }
         | 
| 36 35 | 
             
                  new_version
         | 
| 37 36 | 
             
                end
         | 
| 38 37 |  | 
| 38 | 
            +
                def bump!(level = :patch)
         | 
| 39 | 
            +
                  new_version = increase_version(version, level)
         | 
| 40 | 
            +
                  bump_to_version!(new_version)
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 39 43 | 
             
                [:major, :minor, :patch, :full].each do |level|
         | 
| 40 44 | 
             
                  define_method("bump_#{level}!") { bump!(level) }
         | 
| 41 45 | 
             
                end
         | 
| @@ -57,6 +57,13 @@ module Blacksmith | |
| 57 57 | 
             
                      end
         | 
| 58 58 | 
             
                    end
         | 
| 59 59 |  | 
| 60 | 
            +
                    desc "Bump module to specific version number"
         | 
| 61 | 
            +
                    task :bump_to_version, [:new_version] do |t, args|
         | 
| 62 | 
            +
                      m = Blacksmith::Modulefile.new
         | 
| 63 | 
            +
                      v = m.bump_to_version!(args[:new_version])
         | 
| 64 | 
            +
                      puts "Bumping version to #{args[:new_version]}"
         | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
             | 
| 60 67 | 
             
                    desc "Bump module version to the next patch"
         | 
| 61 68 | 
             
                    task :bump do
         | 
| 62 69 | 
             
                      m = Blacksmith::Modulefile.new
         | 
| @@ -44,10 +44,31 @@ describe 'Blacksmith::Git' do | |
| 44 44 | 
             
                end
         | 
| 45 45 |  | 
| 46 46 | 
             
                describe 'tag!' do
         | 
| 47 | 
            -
                   | 
| 48 | 
            -
             | 
| 49 | 
            -
                     | 
| 50 | 
            -
             | 
| 47 | 
            +
                  context 'basic tag' do
         | 
| 48 | 
            +
                    before { subject.tag!(version) }
         | 
| 49 | 
            +
                    it "should have the tag" do
         | 
| 50 | 
            +
                      out = `cd #{path} && git tag`
         | 
| 51 | 
            +
                      expect(out.chomp).to match(/^v1.0.0$/)
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  context 'signed tag without pattern' do
         | 
| 56 | 
            +
                    before do
         | 
| 57 | 
            +
                      subject.tag_message_pattern = nil
         | 
| 58 | 
            +
                      subject.tag_sign = true
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                    it { expect { subject.tag!(version) }.to raise_error(Blacksmith::Error, /Signed tags require messages/)}
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                  context 'signed tag with pattern' do
         | 
| 65 | 
            +
                    before do
         | 
| 66 | 
            +
                      subject.tag_message_pattern = 'Version %s'
         | 
| 67 | 
            +
                      subject.tag_sign = true
         | 
| 68 | 
            +
                      allow(subject).to receive(:exec_git).with(['tag', 'v1.0.0', '-m', 'Version 1.0.0', '-s']).and_return(true)
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                    it { expect(subject.tag!(version)).to be true }
         | 
| 51 72 | 
             
                  end
         | 
| 52 73 | 
             
                end
         | 
| 53 74 |  | 
| @@ -109,6 +109,10 @@ describe 'Blacksmith::Modulefile' do | |
| 109 109 |  | 
| 110 110 | 
             
              end
         | 
| 111 111 |  | 
| 112 | 
            +
              describe 'bump_to_version' do
         | 
| 113 | 
            +
                it { expect(subject.bump_to_version!("1.0.0")).to eql("1.0.0") }
         | 
| 114 | 
            +
              end
         | 
| 115 | 
            +
             | 
| 112 116 | 
             
              describe 'increase_version' do
         | 
| 113 117 | 
             
                it { expect(subject.increase_version("1.0.0")).to eql("1.0.1") }
         | 
| 114 118 | 
             
                it { expect(subject.increase_version("1.0.1")).to eql("1.0.2") }
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: puppet-blacksmith
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 4.0 | 
| 4 | 
            +
              version: 4.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - MaestroDev
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-12-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rest-client
         | 
| @@ -168,15 +168,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 168 168 | 
             
                  version: '0'
         | 
| 169 169 | 
             
            requirements: []
         | 
| 170 170 | 
             
            rubyforge_project: 
         | 
| 171 | 
            -
            rubygems_version: 2.7. | 
| 171 | 
            +
            rubygems_version: 2.7.3
         | 
| 172 172 | 
             
            signing_key: 
         | 
| 173 173 | 
             
            specification_version: 4
         | 
| 174 174 | 
             
            summary: Tasks to manage Puppet module builds
         | 
| 175 175 | 
             
            test_files:
         | 
| 176 176 | 
             
            - spec/data/Modulefile
         | 
| 177 177 | 
             
            - spec/data/maestrodev-test/metadata.json
         | 
| 178 | 
            -
            - spec/data/metadata.json
         | 
| 179 178 | 
             
            - spec/data/response.json
         | 
| 179 | 
            +
            - spec/data/metadata.json
         | 
| 180 180 | 
             
            - spec/puppet_blacksmith/forge_live_spec.rb
         | 
| 181 181 | 
             
            - spec/puppet_blacksmith/forge_shared.rb
         | 
| 182 182 | 
             
            - spec/puppet_blacksmith/forge_spec.rb
         |