releasinator 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfcb0c0860fd15ef1e4ece2155302b634699dcc2
4
- data.tar.gz: 8aa056a5a1f092e7ac2fafb183b73061bce4e666
3
+ metadata.gz: 514f2117423fc276d733afa1e3ada8409d294c3f
4
+ data.tar.gz: 518e7c826e1ecb8588fddaed5c21de54709d96d3
5
5
  SHA512:
6
- metadata.gz: 6e519b13c6301ede333d82afa4d2a3216cb785000802c1e1b7b3cecdd20f63183d4de46fc34bd4c980b20846555b6bd158f5e1b420d7130083d361c14f00965a
7
- data.tar.gz: efb92b51475f46d51892ea3598af803827fea3555131fcff533ad2387efc6cd7455fa96c90541c199121f6fce103f6de68985f9b7f8a65f8a7f4606273c4f3a6
6
+ metadata.gz: 110da6dcf745e7d20133ae31ba19c6ed6f984bc6447325bb0e00ac8a1331d25220a46f40875950df6967e70b63f98c0b13dad82806f7e91ecd5ea3b156e25392
7
+ data.tar.gz: 025592dcb88660d3270e0b9aa4dafd97d1b54b7acef72a7e3fa06ac47659b2d4eda94a08a940c01c6935019b69d8183fc20820d81ce2752a324770d99e3bc9f2
data/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  Releasinator release notes
2
2
  ==========================
3
3
 
4
+ 0.6.0
5
+ -----
6
+ * Validate all bulleted items in `CHANGELOG.md` end in punctuation.
7
+ * Add new task, `validate:eof_newlines` which validates text files matching a few known extensions end in a newline character. The validation adds the newline character if not present.
8
+ * Validate files are in git with the proper name, case sensitive. Previously, the releasinator would allow files detected by the filesystem. Since Macs are case in-sensitive, incorrect cases for expected filenames were allowed.
9
+
4
10
  0.5.0
5
11
  -----
6
12
  * The releasinator is now Open Source!
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- releasinator (0.5.0)
4
+ releasinator (0.6.0)
5
5
  colorize (~> 0.7)
6
6
  configatron (~> 4.5)
7
7
  json (~> 1.8)
@@ -13,7 +13,7 @@ GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
15
  addressable (2.4.0)
16
- colorize (0.7.7)
16
+ colorize (0.8.0)
17
17
  configatron (4.5.0)
18
18
  faraday (0.9.2)
19
19
  multipart-post (>= 1.2, < 3)
@@ -45,4 +45,4 @@ DEPENDENCIES
45
45
  test-unit (~> 3.1)
46
46
 
47
47
  BUNDLED WITH
48
- 1.11.2
48
+ 1.12.5
data/README.md CHANGED
@@ -34,6 +34,7 @@ release
34
34
 
35
35
  --> validate:all
36
36
  --> validate:paths
37
+ --> validate:eof_newlines
37
38
  --> validate:git_version
38
39
  --> validate:gitignore
39
40
  --> validate:submodules
@@ -122,9 +123,11 @@ The releasinator enforces certain conventions. If a filename closely matches th
122
123
 
123
124
  ## Behind the Scenes
124
125
 
125
- #### Validations
126
+ #### Validations (in no particular order)
126
127
 
128
+ 1. ✓ Validate releasinator version.
127
129
  1. ✓ Validate git version.
130
+ 1. ✓ Validate text files end in newline characters.
128
131
  1. ✓ Validate git's cleanliness (no untracked, unstaged, or uncommitted files).
129
132
  1. ✓ Validate current git branch is up to date with the latest version on server.
130
133
  1. ✓ Validate current git branch is `master` (if no git flow), or `develop` or `release/<Release number>` if using git flow.
data/lib/downstream.rb CHANGED
@@ -154,10 +154,14 @@ module Releasinator
154
154
  if downstream_repo.options.has_key? :new_branch_name
155
155
  new_branch_name = get_new_branch_name(downstream_repo.options[:new_branch_name], @current_release.version)
156
156
  CommandProcessor.command("git push -u origin #{new_branch_name}")
157
+ # TODO - check that the branch exists
158
+ CommandProcessor.command("sleep 5")
157
159
  Publisher.new(@releasinator_config).publish_pull_request(downstream_repo.url, @current_release, @releasinator_config[:product_name], downstream_repo.branch, new_branch_name)
158
160
  else
159
161
  GitUtil.push_branch("master")
160
162
  GitUtil.push_tag(@current_release.version)
163
+ # TODO - check that the tag exists
164
+ CommandProcessor.command("sleep 5")
161
165
  Publisher.new(@releasinator_config).publish(downstream_repo.url, @current_release) unless ! downstream_repo.release_to_github
162
166
  end
163
167
  end
data/lib/git_util.rb CHANGED
@@ -14,6 +14,22 @@ module Releasinator
14
14
  CommandProcessor.command("git fetch origin --prune --recurse-submodules -j9")
15
15
  end
16
16
 
17
+ def self.exist?(path)
18
+ current_branch = get_current_branch()
19
+ # grep is case sensitive, which is what we want. Piped to cat so the grep error code is ignored.
20
+ "" != CommandProcessor.command("git ls-tree --name-only -r #{current_branch} | grep ^#{path}$ | cat")
21
+ end
22
+
23
+ def self.all_files()
24
+ current_branch = get_current_branch()
25
+ CommandProcessor.command("git ls-tree --name-only -r #{current_branch}")
26
+ end
27
+
28
+ def self.move(old_path, new_path)
29
+ puts "Renaming #{old_path} to #{new_path}".yellow
30
+ CommandProcessor.command("git mv -f #{old_path} #{new_path}")
31
+ end
32
+
17
33
  def self.push_branch(branch_name)
18
34
  checkout(branch_name)
19
35
  fetch()
data/lib/printer.rb CHANGED
@@ -12,7 +12,7 @@ module Releasinator
12
12
 
13
13
  def self.check_proceed(warning_msg, abort_msg)
14
14
  puts "#{warning_msg} Continue? (Y/n)".yellow
15
- if 'n' == STDIN.gets.strip
15
+ if 'n' == $stdin.gets.strip
16
16
  self.fail(abort_msg)
17
17
  abort()
18
18
  end
@@ -1,3 +1,3 @@
1
1
  module Releasinator
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -34,7 +34,12 @@ namespace :validate do
34
34
  @downstream.freeze
35
35
  end
36
36
 
37
- desc "validate that git is the correct version"
37
+ desc "validate important text files end in a newline character"
38
+ task :eof_newlines => :config do
39
+ @validator.validate_eof_newlines
40
+ end
41
+
42
+ desc "validate releasinator is up to date"
38
43
  task :releasinator_version => :config do
39
44
  @validator.validate_releasinator_version
40
45
  end
@@ -50,7 +55,7 @@ namespace :validate do
50
55
  @validator.validate_git_version
51
56
  end
52
57
 
53
- desc "validate that git reports no untracked, unstaged, or uncommitted changes"
58
+ desc "validate git reports no untracked, unstaged, or uncommitted changes"
54
59
  task :git => :config do
55
60
  @validator.validate_clean_git
56
61
  end
@@ -124,6 +129,7 @@ namespace :validate do
124
129
  task :all =>
125
130
  [
126
131
  :paths,
132
+ :eof_newlines,
127
133
  :git_version,
128
134
  :gitignore,
129
135
  :submodules,
data/lib/validator.rb CHANGED
@@ -31,6 +31,19 @@ module Releasinator
31
31
  end
32
32
  end
33
33
 
34
+ def validate_eof_newlines
35
+ all_git_files = GitUtil.all_files.split
36
+ text_file_extensions = [".md", ".txt", ".gitignore", "Gemfile", "Gemfile.lock", "LICENSE", "Rakefile", ".rb"]
37
+
38
+ important_git_text_files = all_git_files.select{
39
+ |filename| text_file_extensions.any? { |extension| filename.end_with?(extension) }
40
+ }
41
+
42
+ important_git_text_files.each do |filename|
43
+ CommandProcessor.command("tail -c1 #{filename} | read -r _ || echo >> #{filename}")
44
+ end
45
+ end
46
+
34
47
  def validate_in_path(executable)
35
48
  if "" == CommandProcessor.command("which #{executable} | cat")
36
49
  Printer.fail(executable.bold + " not found on path.")
@@ -54,9 +67,9 @@ module Releasinator
54
67
  end
55
68
  end
56
69
 
57
- def validate_changelog(downstream_dir)
70
+ def validate_changelog(search_ignore_path=nil)
58
71
  validate_base_dir
59
- validate_exist(@releasinator_config.base_dir, "CHANGELOG.md", downstream_dir, ["release_notes.md"])
72
+ validate_exist(@releasinator_config.base_dir, "CHANGELOG.md", search_ignore_path, ["release_notes.md"])
60
73
 
61
74
  changelog_contents = get_changelog_contents
62
75
  ValidatorChangelog.new(@releasinator_config).validate_changelog_contents(changelog_contents)
@@ -179,29 +192,29 @@ module Releasinator
179
192
  abort()
180
193
  end
181
194
 
182
- def validate_exist(dir, expected_file_name, downstream_dir, alternate_names=[])
195
+ def validate_exist(dir, expected_file_name, search_ignore_path=nil, alternate_names=[])
183
196
  if !File.exist? dir
184
197
  Printer.fail("Directory #{dir} not found.")
185
198
  abort()
186
199
  end
187
200
 
188
201
  Dir.chdir(dir) do
189
- if !File.exist?(expected_file_name)
202
+ if !GitUtil.exist?(expected_file_name)
190
203
  puts "#{dir}/#{expected_file_name} not found. Searching for similar files.".yellow
191
204
 
192
205
  # search for files that are somewhat similar to the file being searched, ignoring case
193
206
  filename_prefix = expected_file_name[0,5]
194
- similar_files = CommandProcessor.command("find . -type f -not -path \"./#{downstream_dir}/*\" -iname '#{filename_prefix}*'| sed 's|./||'").strip
207
+ similar_files = CommandProcessor.command("find . -type f -not -path \"./#{search_ignore_path}/*\" -iname '#{filename_prefix}*'| sed 's|./||'").strip
195
208
  num_similar_files = similar_files.split.count
196
209
  puts similar_files
197
210
  if num_similar_files == 1
198
- Printer.check_proceed("Found a single similar file: #{similar_files}. Do you want to rename this to the expected #{expected_file_name}?","Please place #{dir}/#{expected_file_name}")
211
+ Printer.check_proceed("Found a single similar file: #{similar_files}. Do you want to rename this to the expected #{expected_file_name}?","Please commit #{dir}/#{expected_file_name}")
199
212
  rename_file(similar_files, expected_file_name)
200
213
  elsif num_similar_files > 1
201
214
  Printer.fail("Found more than 1 file similar to #{expected_file_name}. Please rename one, and optionally remove the others to not confuse users.")
202
215
  abort()
203
216
  elsif !rename_alternate_name(expected_file_name, alternate_names)
204
- Printer.fail("Please place #{dir}/#{expected_file_name}.")
217
+ Printer.fail("Please commit #{dir}/#{expected_file_name}.")
205
218
  abort()
206
219
  end
207
220
  end
@@ -352,8 +365,7 @@ module Releasinator
352
365
  def rename_file(old_name, new_name)
353
366
  is_git_already_clean = GitUtil.is_clean_git?
354
367
 
355
- puts "Renaming #{old_name} to expected filename: #{new_name}".yellow
356
- CommandProcessor.command("mv #{old_name} #{new_name}")
368
+ GitUtil.move(old_name, new_name)
357
369
  # fix any references to file in readme
358
370
  replace_string("README.md", "(#{old_name})", "(#{new_name})")
359
371
  if is_git_already_clean
@@ -94,8 +94,24 @@ module Releasinator
94
94
 
95
95
  validate_semver(changelog_hash)
96
96
 
97
+ changelog_hash.each { |release, changelog|
98
+ validate_single_changelog_entry(changelog)
99
+ }
100
+
97
101
  latest_release, latest_release_changelog = changelog_hash.first
98
102
  CurrentRelease.new(latest_release, latest_release_changelog)
99
103
  end
104
+
105
+ def validate_single_changelog_entry(entry)
106
+ lines = entry.split(/\r?\n/)
107
+ lines.each{ |line|
108
+ if line.match /^\s*\*\s+.*$/ # regex matches bulleted points
109
+ if !line.match /^\s*\*\s+.*[\!,\?:\.]$/ # regex matches bullet points with punctuation
110
+ Printer.fail("'#{line}' is invalid. Bulleted points should end in punctuation.")
111
+ abort()
112
+ end
113
+ end
114
+ }
115
+ end
100
116
  end
101
117
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PayPal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2016-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler