community_cookbook_releaser 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ccr +30 -29
  3. metadata +4 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a35e1e2f755dabcafc467125b67ddd5583c55f54dd276e52e8d9ed99467a221
4
- data.tar.gz: bd66b145e988c158f534f6ce09e84e2faf188bce4fb6c4a598243fb4f98ed854
3
+ metadata.gz: 91c7f7ce05176cb4c34b82d012684def2edac14cd36f53dac3c16cebe543aa9c
4
+ data.tar.gz: 67a732b440a96857d11147f44718f417fc91e6c9a66776df3e91ce8bf4524bd1
5
5
  SHA512:
6
- metadata.gz: ab08ffc469629a6e2613ff19757f8ca25f6de7a780718f7917d8d28556a46fae363c440112a56c9e8ebd77e8286f7bf9b06cd696b2462a0abddbf4f0c5f606ce
7
- data.tar.gz: 84487e580754ef8b759c807c47b23fb1afb36bf9c81a2f52c65929ba1168242db4ff4cb3fbb8d3dd8f1e8653f0e2dc6f9aabdb97fd76ad3dbbc925c9e1ff9198
6
+ metadata.gz: 4b138e304cd8eaad05329489a14f95273a6a61541d7b1dda97e7f791242e16a4e1280c88c9759f7a104042d22d6200b68479cda7bb5db1faf061f5a08b8b9450
7
+ data.tar.gz: 6f7c2708a15353365764eaa341dd7b00b8fde1a2dae25612ba8cab30b82fed59f2dd24978cd6e576276bef118cd476e48cdc0f74b9000d7905fbcf29ecc5eb2e
data/bin/ccr CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'time'
4
- require 'yaml'
5
- require 'octokit'
3
+ require "time"
4
+ require "yaml"
5
+ require "octokit"
6
6
 
7
7
  def puts_red(text)
8
8
  puts "\033[31m#{text}\e[0m"
@@ -16,27 +16,27 @@ def file_or_error(filename)
16
16
  end
17
17
 
18
18
  def fail_if_cb_files
19
- file_or_error('metadata.rb')
20
- file_or_error('CHANGELOG.md')
19
+ file_or_error("metadata.rb")
20
+ file_or_error("CHANGELOG.md")
21
21
 
22
- unless File.open('CHANGELOG.md').read =~ /This file is used/
23
- puts_red('CHANGELOG.md is not in the standard changelog format. Cannot determine where to insert new changes!')
22
+ unless File.open("CHANGELOG.md").read =~ /This file is used/
23
+ puts_red("CHANGELOG.md is not in the standard changelog format. Cannot determine where to insert new changes!")
24
24
  exit 1
25
25
  end
26
26
 
27
- unless File.open('metadata.rb').read =~ /version\s*('|")\d*.\d*.\d*('|")/
27
+ unless File.open("metadata.rb").read =~ /version\s*('|")\d*.\d*.\d*('|")/
28
28
  puts_red("metadata.rb doesn't appear to have a valid version string!")
29
29
  exit 1
30
30
  end
31
31
  end
32
32
 
33
33
  def parse_config
34
- file_or_error('~/.ccr_config.yml')
34
+ file_or_error("~/.ccr_config.yml")
35
35
 
36
- yconfig = YAML.load_file(File.expand_path('~/.ccr_config.yml'))
37
- yconfig['github_organization'] ||= 'chef-cookbooks'
36
+ yconfig = YAML.load_file(File.expand_path("~/.ccr_config.yml"))
37
+ yconfig["github_organization"] ||= "chef-cookbooks"
38
38
 
39
- unless yconfig['token']
39
+ unless yconfig["token"]
40
40
  puts_red("~/.ccr_config.yml does not contain a 'token' value. Cannot continue without a Github token!")
41
41
  exit 1
42
42
  end
@@ -49,43 +49,43 @@ def config
49
49
  end
50
50
 
51
51
  def bump_version(old_version)
52
- bumped = old_version.split('.').map(&:to_i)
52
+ bumped = old_version.split(".").map(&:to_i)
53
53
  bumped[2] += 1
54
- bumped.join('.')
54
+ bumped.join(".")
55
55
  end
56
56
 
57
57
  def current_metadata_version
58
- File.open('metadata.rb').read.match(/version\s*('|")(\d*.\d*.\d*)('|")/)[2]
58
+ File.open("metadata.rb").read.match(/version\s*('|")(\d*.\d*.\d*)('|")/)[2]
59
59
  end
60
60
 
61
61
  def prompted_new_version
62
- current_version = File.open('metadata.rb').read.match(/version\s*('|")(\d*.\d*.\d*)('|")/)[2]
62
+ current_version = File.open("metadata.rb").read.match(/version\s*('|")(\d*.\d*.\d*)('|")/)[2]
63
63
  next_version = bump_version(current_version)
64
64
 
65
65
  print "New version to release [autobump to #{next_version}]: "
66
66
 
67
67
  provided = gets.chomp
68
- next_version = provided unless provided == '' # use the auto increment if nothing provided
68
+ next_version = provided unless provided == "" # use the auto increment if nothing provided
69
69
  next_version
70
70
  end
71
71
 
72
72
  # update the version line in a way that we maintain formatting and don't accidently
73
73
  # match a depends line further down in the cookbook with the same string
74
74
  def update_metadata_version(old_version, new_version)
75
- contents = File.read('metadata.rb')
75
+ contents = File.read("metadata.rb")
76
76
  old_version_line = /^version.*/.match(contents)[0]
77
77
  new_version_line = old_version_line.gsub(old_version, new_version)
78
78
  new_contents = contents.gsub(old_version_line, new_version_line)
79
- File.open('metadata.rb', 'w') { |file| file.write(new_contents) }
79
+ File.open("metadata.rb", "w") { |file| file.write(new_contents) }
80
80
  end
81
81
 
82
82
  def write_updated_changelog(new_version)
83
- temp_content = ''
83
+ temp_content = ""
84
84
  # read in the old content to a tempstring and insert our new content where appropriate
85
- File.open('CHANGELOG.md', 'r').each_line do |line|
85
+ File.open("CHANGELOG.md", "r").each_line do |line|
86
86
  if line =~ /^This file/
87
87
  temp_content << "#{line}\n"
88
- temp_content << "## #{new_version} (#{Time.now.strftime('%Y-%m-%d')})\n\n"
88
+ temp_content << "## #{new_version} (#{Time.now.strftime("%Y-%m-%d")})\n\n"
89
89
  changes_since_last_tag.each do |change|
90
90
  temp_content << "- #{change}\n"
91
91
  end
@@ -95,20 +95,21 @@ def write_updated_changelog(new_version)
95
95
  end
96
96
 
97
97
  # write out our updated changelog content
98
- File.open('CHANGELOG.MD', 'w') { |file| file.write(temp_content) }
98
+ File.open("CHANGELOG.MD", "w") { |file| file.write(temp_content) }
99
99
  end
100
100
 
101
101
  def changes_since_last_tag
102
- client = Octokit::Client.new(access_token: config['token'])
102
+ client = Octokit::Client.new(access_token: config["token"])
103
103
  Octokit.auto_paginate = true
104
104
  cb_name = File.split(Dir.getwd)[-1]
105
- last_tag_sha = client.tags("#{config['github_organization']}/#{cb_name}")[0][:commit][:sha]
106
- commit_data = client.compare("#{config['github_organization']}/#{cb_name}", last_tag_sha, 'master')
105
+ last_tag_sha = client.tags("#{config["github_organization"]}/#{cb_name}")[0][:commit][:sha]
106
+ commit_data = client.compare("#{config["github_organization"]}/#{cb_name}", last_tag_sha, "master")
107
107
  commit_messages = []
108
- commit_data['commits'].each do |commit|
109
- msg = commit['commit']['message'].split("\n")[0] # get just the commit title not the entire thing
108
+ commit_data["commits"].each do |commit|
109
+ msg = commit["commit"]["message"].split("\n")[0] # get just the commit title not the entire thing
110
110
  next if msg =~ /^Merge pull request.*/
111
- msg << " - [@#{commit[:author][:login]}](#{commit[:author][:html_url]})"
111
+
112
+ msg << " - [@#{commit[:author][:login]}](#{commit[:author][:html_url]})" unless commit[:author].nil? # author is nil if the account was deleted before the merge happened
112
113
  commit_messages << msg
113
114
  end
114
115
  commit_messages
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: community_cookbook_releaser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-09 00:00:00.000000000 Z
11
+ date: 2019-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -48,15 +48,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  requirements:
49
49
  - - ">="
50
50
  - !ruby/object:Gem::Version
51
- version: 2.2.0
51
+ version: 2.3.0
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubyforge_project:
59
- rubygems_version: 2.7.7
58
+ rubygems_version: 3.0.3
60
59
  signing_key:
61
60
  specification_version: 4
62
61
  summary: A simple script in gem form for releasing chef managed community cookbooks.