auto find prev tag

This commit is contained in:
Petr Korolev 2014-11-04 16:52:28 +02:00
parent 7668e974eb
commit cf741d9a7c

View File

@ -20,22 +20,29 @@ def exec_command(cmd)
%x[cd #{@project_path} && #{cmd}] %x[cd #{@project_path} && #{cmd}]
end end
def findTagsDates(tag1, tag2) def findPrevTagDate
value1 = exec_command "git log --tags --simplify-by-decoration --pretty=\"format:%ci %d\" | grep #{tag1}"
value1 = exec_command "git log --tags --simplify-by-decoration --pretty=\"format:%ci %d\" | grep tag"
unless value1 unless value1
puts 'not found this tag' puts 'not found this tag'
exit exit
end end
scan_results = value1.scan(/.*tag.*/)
unless /(.*)\s\(.*\)/.match(value1)[1] prev_tag = scan_results[1]
unless scan_results.count
puts 'Not found any versions' puts 'Not found any versions'
exit exit
end end
time = Time.parse(/(.*)\s\(.*\)/.match(value1)[1]) puts "Prev tag is #{prev_tag}"
time = Time.parse(prev_tag)
end end
def getAllClosedPullRequests def getAllClosedPullRequests
github = Github.new oauth_token: '8587bb22f6bf125454768a4a19dbcc774ea68d48' github = Github.new oauth_token: '8587bb22f6bf125454768a4a19dbcc774ea68d48'
issues = github.pull_requests.list 'skywinder', 'ActionSheetPicker-3.0', :state => 'closed' issues = github.pull_requests.list 'skywinder', 'ActionSheetPicker-3.0', :state => 'closed'
@ -54,11 +61,12 @@ def compund_changelog (tag_time, pull_requests)
log = '' log = ''
last_tag = exec_command('git describe --abbrev=0 --tags').strip last_tag = exec_command('git describe --abbrev=0 --tags').strip
log += "## [#{last_tag}] (https://github.com/#{@github_user}/#{@github_repo_name}/tree/#{last_tag})\n" log += "## [#{last_tag}] (https://github.com/#{@github_user}/#{@github_repo_name}/tree/#{last_tag})\n"
time_string = tag_time.strftime "%Y/%m/%d" time_string = tag_time.strftime "%Y/%m/%d"
log += "#### #{time_string}\n" log += "#### #{time_string}\n"
pull_requests.each { |dict| pull_requests.each { |dict|
merge = "#{dict[:title]} (##{dict[:number]})\n" merge = "#{dict[:title]} ([\\##{dict[:number]}](https://github.com/#{@github_user}/#{@github_repo_name}/pull/#{dict[:number]}))\n"
log += "- #{merge}" log += "- #{merge}"
} }
@ -67,7 +75,7 @@ def compund_changelog (tag_time, pull_requests)
end end
tag_time = findTagsDates tag1, tag2 tag_time = findPrevTagDate
pull_requests = getAllClosedPullRequests pull_requests = getAllClosedPullRequests