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) bumped_version = bump_version(versions_array)
unless @options[:dry_run] unless @options[:dry_run]
puts 'Are you sure? Click Y to continue:' puts 'Are you sure? Press Y to continue:'
str = gets.chomp str = gets.chomp
if str != 'Y' if str != 'Y'
puts '-> exit' puts '-> exit'
@ -196,7 +196,6 @@ def run_bumping_script
execute_line_if_not_dry_run("gem build #{spec_file}") execute_line_if_not_dry_run("gem build #{spec_file}")
gem = find_current_gem_file gem = find_current_gem_file
execute_line_if_not_dry_run("gem push #{gem}") execute_line_if_not_dry_run("gem push #{gem}")
# execute_line_if_not_dry_run("pod trunk push #{spec_file}") # execute_line_if_not_dry_run("pod trunk push #{spec_file}")
@ -206,7 +205,7 @@ def revert_last_bump
spec_file = find_spec_file spec_file = find_spec_file
result, _ = find_version_in_podspec(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 str = gets.chomp
if str != 'Y' if str != 'Y'
puts '-> exit' puts '-> exit'

View File

@ -117,9 +117,14 @@ class ChangelogGenerator
puts "Receive tags for repo #{url}" puts "Receive tags for repo #{url}"
end end
if @options[:token]
response = HTTParty.get(url, response = HTTParty.get(url,
:headers => {'Authorization' => "token #{@options[:token]}", :headers => {'Authorization' => "token #{@options[:token]}",
'User-Agent' => 'Changelog-Generator'}) 'User-Agent' => 'Changelog-Generator'})
else
response = HTTParty.get(url,
:headers => {'User-Agent' => 'Changelog-Generator'})
end
json_parse = JSON.parse(response.body) json_parse = JSON.parse(response.body)

View File

@ -3,14 +3,14 @@ require 'optparse'
class Parser class Parser
def self.parse_options 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| parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator --user username --project project_name [options]' opts.banner = 'Usage: changelog_generator [options]'
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo (required)') do |last| opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo') do |last|
options[:user] = last options[:user] = last
end 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 options[:project] = last
end 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| 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 exit
end 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] if !options[:user] || !options[:project]
puts parser.banner puts parser.banner
exit exit