cookbook-release 1.1.5 → 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTI4MmYxOTQ2MTZkMTBjYzZkMDlhMGNiNzk2NGFlZmU4Y2NmMWY2NQ==
4
+ NjE4ODBmMzczNjhkNzcyNGZlZTJlYjZjYTZjYzU5ZDlmNWE0NWYyNw==
5
5
  data.tar.gz: !binary |-
6
- MTRkNTc4MmIyMWRjN2VmM2U2M2I3ZGJlNWVhZGI0MWYwNjZjYjhmMw==
6
+ YmZlZmI2ZTUzN2M5ZGI0ZmI5ZTI2NGM4YWQyZTY2ZjczNzEyODQyNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzVkNzZmZjNmYjdjNDg2Y2M1ZjFmNDU4ODJlMTliM2ZkOGE4MTIxMTM1NzNm
10
- MGJmZTU4NmFiMTRiNWJjNjhkOWFjNTI0MDFjMmMyZGNmM2VlNjU0MTFlMDg0
11
- ZDEyNDBhY2JkMmIyNGRkZDU4Yjk2NzJmMjZhMjhmMzQxOTRkMDI=
9
+ MzY5NWU3ZjhjZDc0MmMyMTM3MGQ0NTMxNDFlMTg3Njk2MjlhYjI1ODJhNDE2
10
+ YWQyZjRjYmFmYWU3MzIzYTc4OTAzNmU0OGE0NDY3NWIwZmZkNTY2ZTUxNjRm
11
+ NWJhOGJjOTViYjc0NTY5Nzk3NWFkOTNmMDdhMTc3NjhkOWNlNzQ=
12
12
  data.tar.gz: !binary |-
13
- YzhiODZlYzc4OTllZmNhYzk3NTAyYWZkMzg3YzJiYzlkNWRjMjk2ZTExMzk5
14
- YWUxMDA3OTJmZmZmMzAyNjhmMzE5MzUzNjI4OWM5NmI2MTFiMGRiNDYwNDk3
15
- NGFkMDRhNWZkODUxMzY2Y2Q2OWFjNzY4MmY5ZDIxNGE4ZThlMzg=
13
+ YjZkY2JiMjdhOTExZmFmMGFlMzdjZTQwNDg4YWY1YzYyYzI5ZGU2MDQzMjk0
14
+ OTBhZTk1MmRmOTQzZmQ2Yjc2ZjgyMTk5MGJmOTViNDBmZTIyZjVkYmFkMmY5
15
+ MTFhZGVlZGI0MjIyNTI4MmU2NTQzZGNjOWEzZmNkMDE4OTU3YmQ=
@@ -6,7 +6,7 @@ require 'English'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'cookbook-release'
9
- spec.version = '1.1.5'
9
+ spec.version = '1.1.6'
10
10
  spec.authors = ['Grégoire Seux']
11
11
  spec.email = 'g.seux@criteo.com'
12
12
  spec.summary = 'Provide primitives (and rake tasks) to release a cookbook'
@@ -4,6 +4,7 @@ module CookbookRelease
4
4
  DEFAULT_OPTS = {
5
5
  expand_major: true,
6
6
  expand_risky: true,
7
+ short_sha: true
7
8
  }
8
9
 
9
10
  def initialize(git, opts = {})
@@ -47,7 +48,7 @@ module CookbookRelease
47
48
 
48
49
  def changelog
49
50
  ref = ENV['RELEASE_BRANCH'] || 'origin/master'
50
- @git.compute_changelog(ref)
51
+ @git.compute_changelog(ref, @opts[:short_sha])
51
52
  end
52
53
  end
53
54
  end
@@ -19,7 +19,7 @@ module CookbookRelease
19
19
  end
20
20
 
21
21
  def self.git?(dir)
22
- @g.index.readable?
22
+ !@g.nil?
23
23
  end
24
24
 
25
25
  def reset_command(new_version)
@@ -62,13 +62,13 @@ module CookbookRelease
62
62
  last.to_version
63
63
  end
64
64
 
65
- def compute_changelog(since)
65
+ def compute_changelog(since, short_sha = true)
66
66
  commits = @g.log.between(since, 'HEAD').map do |commit|
67
67
  message = commit.message.lines.map(&:chomp).compact.delete_if(&:empty?)
68
68
  Commit.new(
69
69
  author: commit.author.name,
70
70
  subject: message.delete_at(0),
71
- hash: commit.sha,
71
+ hash: short_sha ? commit.sha[0,7] : commit.sha,
72
72
  body: message.empty? ? nil : message.join('\n')
73
73
  )
74
74
  end.reject { |commit| commit[:subject] =~ /^Merge branch (.*) into/i }
data/spec/git_spec.rb CHANGED
@@ -12,6 +12,8 @@ describe CookbookRelease::GitUtilities do
12
12
  git init .
13
13
  git config user.email "you@example.com"
14
14
  git config user.name Hello
15
+ git commit --allow-empty -m 'none'
16
+ git tag 1.0.0
15
17
  EOH
16
18
  cmds.split("\n").each do |cmd|
17
19
  cmd = Mixlib::ShellOut.new(cmd)
@@ -65,10 +67,6 @@ describe CookbookRelease::GitUtilities do
65
67
  describe '.compute_last_release' do
66
68
  it 'finds the last release' do
67
69
  cmds = <<-EOH
68
- touch toto
69
- git add toto
70
- git commit -m'none'
71
- git tag 1.0.0
72
70
  git commit --allow-empty -m 'none'
73
71
  git tag 1.2.43
74
72
  git commit --allow-empty -m 'none'
@@ -88,10 +86,6 @@ describe CookbookRelease::GitUtilities do
88
86
  describe '.compute_changelog' do
89
87
  it 'find the proper changelog' do
90
88
  cmds = <<-EOH
91
- touch toto
92
- git add toto
93
- git commit -m'none'
94
- git tag 1.0.0
95
89
  git commit --allow-empty -m 'A commit'
96
90
  git commit --allow-empty -m 'Another commit'
97
91
  git commit --allow-empty -m 'A third one'
@@ -109,10 +103,6 @@ describe CookbookRelease::GitUtilities do
109
103
 
110
104
  it 'parse correctly commits' do
111
105
  cmds = <<-EOH
112
- touch toto
113
- git add toto
114
- git commit -m'none'
115
- git tag 1.0.0
116
106
  git commit --allow-empty -m "subject" -m "body"
117
107
  git commit --allow-empty -m "without body"
118
108
  EOH
@@ -128,5 +118,23 @@ describe CookbookRelease::GitUtilities do
128
118
  expect(changelog[1][:body]).to eq('body')
129
119
  expect(changelog[0][:body]).to be_nil
130
120
  end
121
+
122
+ it 'can use short sha' do
123
+ cmd = Mixlib::ShellOut.new('git commit --allow-empty -m "subject"')
124
+ cmd.run_command
125
+ cmd.error!
126
+
127
+ changelog = git.compute_changelog('HEAD~1', true)
128
+ expect(changelog[0][:hash].size).to eq(7)
129
+ end
130
+
131
+ it 'can use long sha' do
132
+ cmd = Mixlib::ShellOut.new('git commit --allow-empty -m "subject"')
133
+ cmd.run_command
134
+ cmd.error!
135
+
136
+ changelog = git.compute_changelog('HEAD~1', false)
137
+ expect(changelog[0][:hash].size).to eq(40)
138
+ end
131
139
  end
132
140
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cookbook-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grégoire Seux