Merge branch 'new-features'

This commit is contained in:
Petr Korolev 2014-11-10 14:45:15 +02:00
commit c55881bdfa
4 changed files with 32 additions and 16 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
/lib/CHANGELOG.md

View File

@ -179,7 +179,7 @@ def run_bumping_script
bumped_version = bump_version(versions_array)
unless @options[:dry_run]
puts 'Are you sure? Click Y to continue:'
puts 'Are you sure? Press Y to continue:'
str = gets.chomp
if str != 'Y'
puts '-> exit'
@ -196,7 +196,6 @@ def run_bumping_script
execute_line_if_not_dry_run("gem build #{spec_file}")
gem = find_current_gem_file
execute_line_if_not_dry_run("gem push #{gem}")
# execute_line_if_not_dry_run("pod trunk push #{spec_file}")
@ -206,7 +205,7 @@ def revert_last_bump
spec_file = find_spec_file
result, _ = find_version_in_podspec(spec_file)
puts "DELETE tag #{result} and HARD reset HEAD~1?\nClick Y to continue:"
puts "DELETE tag #{result} and HARD reset HEAD~1?\nPress Y to continue:"
str = gets.chomp
if str != 'Y'
puts '-> exit'

View File

@ -60,7 +60,7 @@ class ChangelogGenerator
tag1 = @options[:tag1]
tag2 = @options[:tag2]
tags_strings = []
self.all_tags.each { |x| tags_strings.push(x['name'])}
self.all_tags.each { |x| tags_strings.push(x['name']) }
if tags_strings.include?(tag1)
if tags_strings.include?(tag2)
@ -117,9 +117,14 @@ class ChangelogGenerator
puts "Receive tags for repo #{url}"
end
response = HTTParty.get(url,
:headers => {'Authorization' => "token #{@options[:token]}",
'User-Agent' => 'Changelog-Generator'})
if @options[:token]
response = HTTParty.get(url,
:headers => {'Authorization' => "token #{@options[:token]}",
'User-Agent' => 'Changelog-Generator'})
else
response = HTTParty.get(url,
:headers => {'User-Agent' => 'Changelog-Generator'})
end
json_parse = JSON.parse(response.body)
@ -160,7 +165,7 @@ class ChangelogGenerator
issues = Array.new(@issues)
issues.delete_if{ |issue|
issues.delete_if { |issue|
if issue[:closed_at]
t = Time.parse(issue[:closed_at]).utc
tag_is_later_since = t > since_tag_time
@ -196,7 +201,7 @@ class ChangelogGenerator
issues = Array.new(@issues)
issues.delete_if{ |issue|
issues.delete_if { |issue|
if issue[:closed_at]
t = Time.parse(issue[:closed_at]).utc
t > tag_time
@ -234,19 +239,19 @@ class ChangelogGenerator
if issues
issues.each { |dict|
is_bug = false
is_enhancement = false
is_enhancement = false
dict.labels.each { |label|
if label.name == 'bug'
is_bug = true
end
if label.name == 'enhancement'
is_enhancement = true
is_enhancement = true
end
}
intro = 'Closed issue'
if is_bug
intro = 'Fixed bug'
intro = 'Fixed bug'
end
if is_enhancement

View File

@ -3,14 +3,14 @@ require 'optparse'
class Parser
def self.parse_options
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true }
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true}
parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator --user username --project project_name [options]'
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo (required)') do |last|
opts.banner = 'Usage: changelog_generator [options]'
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
options[:user] = last
end
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub (required)') do |last|
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub') do |last|
options[:project] = last
end
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this script required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications') do |last|
@ -51,6 +51,17 @@ class Parser
exit
end
if !options[:user] && !options[:project]
remote = `git remote -vv`.split("\n")
match = /.*(?:[:\/])(\w*)\/((?:-|\w)*)\.git.*/.match(remote[0])
if match[1] && match[2]
puts "Detected user:#{match[1]}, project:#{match[2]}"
options[:user], options[:project] = match[1], match[2]
end
end
if !options[:user] || !options[:project]
puts parser.banner
exit