fix formatting
This commit is contained in:
parent
dee26a0954
commit
a383da3848
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
output.txt
|
output.txt
|
||||||
constants.rb
|
constants.rb
|
||||||
|
output.md
|
||||||
|
|
|
@ -20,6 +20,8 @@ class ChangelogGenerator
|
||||||
end
|
end
|
||||||
@all_tags = self.get_all_tags
|
@all_tags = self.get_all_tags
|
||||||
@pull_requests = self.get_all_closed_pull_requests
|
@pull_requests = self.get_all_closed_pull_requests
|
||||||
|
|
||||||
|
@tag_times_hash = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def print_json(json)
|
def print_json(json)
|
||||||
|
@ -40,9 +42,6 @@ class ChangelogGenerator
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts 'Receive all pull requests'
|
puts 'Receive all pull requests'
|
||||||
# json.each { |dict|
|
|
||||||
# p "##{dict[:number]} - #{dict[:title]} (#{dict[:closed_at]})"
|
|
||||||
# }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json
|
json
|
||||||
|
@ -78,19 +77,22 @@ class ChangelogGenerator
|
||||||
puts "Can't find tag #{tag1} -> exit"
|
puts "Can't find tag #{tag1} -> exit"
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
log += self.generate_log_for_all_tags
|
log += self.generate_log_for_all_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
puts log
|
puts log
|
||||||
File.open('output.txt', 'w') { |file| file.write(log) }
|
File.open('output.md', 'w') { |file| file.write(log) }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_log_for_all_tags
|
def generate_log_for_all_tags
|
||||||
log = self.generate_log_between_tags(self.all_tags[0], self.all_tags[1])
|
log = ''
|
||||||
|
for index in 1 ... self.all_tags.size
|
||||||
|
log += self.generate_log_between_tags(self.all_tags[index-1], self.all_tags[index])
|
||||||
|
end
|
||||||
|
|
||||||
|
log
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_megred(number)
|
def is_megred(number)
|
||||||
|
@ -126,7 +128,6 @@ class ChangelogGenerator
|
||||||
|
|
||||||
def generate_log_between_tags(since_tag, till_tag)
|
def generate_log_between_tags(since_tag, till_tag)
|
||||||
|
|
||||||
log = ''
|
|
||||||
since_tag_time = self.get_time_of_tag(since_tag)
|
since_tag_time = self.get_time_of_tag(since_tag)
|
||||||
till_tag_time = self.get_time_of_tag(till_tag)
|
till_tag_time = self.get_time_of_tag(till_tag)
|
||||||
|
|
||||||
|
@ -136,7 +137,7 @@ class ChangelogGenerator
|
||||||
since_tag_time, till_tag_time = till_tag_time, since_tag_time
|
since_tag_time, till_tag_time = till_tag_time, since_tag_time
|
||||||
end
|
end
|
||||||
|
|
||||||
since_tag_name = since_tag['name']
|
till_tag_name = till_tag['name']
|
||||||
|
|
||||||
pull_requests = Array.new(@pull_requests)
|
pull_requests = Array.new(@pull_requests)
|
||||||
|
|
||||||
|
@ -149,14 +150,14 @@ class ChangelogGenerator
|
||||||
!in_range
|
!in_range
|
||||||
}
|
}
|
||||||
|
|
||||||
self.create_log(pull_requests, since_tag_name, since_tag_time)
|
self.create_log(pull_requests, till_tag_name, till_tag_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_log(pull_requests, since_tag_name, since_tag_time)
|
def create_log(pull_requests, tag_name, tag_time)
|
||||||
log = ''
|
|
||||||
log += "## [#{since_tag_name}] (https://github.com/#{$github_user}/#{$github_repo_name}/tree/#{since_tag_name})\n"
|
|
||||||
|
|
||||||
time_string = since_tag_time.strftime "%Y/%m/%d"
|
log = "## [#{tag_name}] (https://github.com/#{$github_user}/#{$github_repo_name}/tree/#{tag_name})\n"
|
||||||
|
|
||||||
|
time_string = tag_time.strftime "%d/%m/%y"
|
||||||
log += "#### #{time_string}\n"
|
log += "#### #{time_string}\n"
|
||||||
|
|
||||||
pull_requests.each { |dict|
|
pull_requests.each { |dict|
|
||||||
|
@ -168,6 +169,10 @@ class ChangelogGenerator
|
||||||
|
|
||||||
def get_time_of_tag(prev_tag)
|
def get_time_of_tag(prev_tag)
|
||||||
|
|
||||||
|
if @tag_times_hash[prev_tag['name']]
|
||||||
|
return @tag_times_hash[prev_tag['name']]
|
||||||
|
end
|
||||||
|
|
||||||
if @options[:verbose]
|
if @options[:verbose]
|
||||||
puts "Get time for tag #{prev_tag['name']}"
|
puts "Get time for tag #{prev_tag['name']}"
|
||||||
end
|
end
|
||||||
|
@ -175,6 +180,7 @@ class ChangelogGenerator
|
||||||
github_git_data_commits_get = @github.git_data.commits.get $github_user, $github_repo_name, prev_tag['commit']['sha']
|
github_git_data_commits_get = @github.git_data.commits.get $github_user, $github_repo_name, prev_tag['commit']['sha']
|
||||||
time_string = github_git_data_commits_get['committer']['date']
|
time_string = github_git_data_commits_get['committer']['date']
|
||||||
Time.parse(time_string)
|
Time.parse(time_string)
|
||||||
|
@tag_times_hash[prev_tag['name']] = Time.parse(time_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -184,5 +190,4 @@ if __FILE__ == $0
|
||||||
log_generator = ChangelogGenerator.new
|
log_generator = ChangelogGenerator.new
|
||||||
|
|
||||||
log_generator.compund_changelog
|
log_generator.compund_changelog
|
||||||
# log_generator.generate_log_between_tags(tags[1], tags[2])
|
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user