Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6682ffe452 | ||
|
|
dbc7b3e567 | ||
|
|
a96f74208c | ||
|
|
cdc009b4ad | ||
|
|
0046f344a9 | ||
|
|
1b792bc67b | ||
|
|
f0716771b5 | ||
|
|
50dd7b2ed6 | ||
|
|
3797b3ac31 | ||
|
|
f08685b015 | ||
|
|
fc96007741 | ||
|
|
7e2826e3b8 | ||
|
|
c55881bdfa | ||
|
|
f6f9facc71 | ||
|
|
807bacd95a | ||
|
|
936b191566 | ||
|
|
a33b52d6d0 | ||
|
|
337c9a7d59 | ||
|
|
8247fd8520 | ||
|
|
223cd2640c | ||
|
|
2db69dd27c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -0,0 +1 @@
|
||||
/lib/CHANGELOG.md
|
||||
|
||||
30
CHANGELOG.md
30
CHANGELOG.md
@@ -1,22 +1,34 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.0)
|
||||
#### 10/11/14
|
||||
- *Implemented enhancement:* Detect username and project form origin [\#11](https://github.com/skywinder/Github-Changelog-Generator/issues/11)
|
||||
|
||||
- *Fixed bug:* Markdown formating in the last line wrong [\#9](https://github.com/skywinder/Github-Changelog-Generator/issues/9)
|
||||
|
||||
- *Fixed bug:* Bug with wrong credentials in 1.0.1 [\#12](https://github.com/skywinder/Github-Changelog-Generator/issues/12)
|
||||
|
||||
## [1.0.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.1)
|
||||
#### 10/11/14
|
||||
- *Merged pull-request:* Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8)
|
||||
|
||||
## [1.0.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0)
|
||||
#### 07/11/14
|
||||
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7)
|
||||
- *Merged pull-request:* Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7)
|
||||
|
||||
- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3)
|
||||
|
||||
- *Fixed bug:* Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)
|
||||
|
||||
- *Implemented enhancement:* Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/Github-Changelog-Generator/issues/6)
|
||||
- *Merged pull-request:* Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3)
|
||||
|
||||
- *Implemented enhancement:* Implement option to specify output filename [\#4](https://github.com/skywinder/Github-Changelog-Generator/issues/4)
|
||||
|
||||
- *Implemented enhancement:* Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/Github-Changelog-Generator/issues/6)
|
||||
|
||||
- *Fixed bug:* Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)
|
||||
|
||||
## [0.1.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0)
|
||||
#### 07/11/14
|
||||
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2)
|
||||
- *Merged pull-request:* Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2)
|
||||
|
||||
- Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1)
|
||||
- *Merged pull-request:* Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1)
|
||||
|
||||
## [0.0.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.2)
|
||||
#### 06/11/14
|
||||
@@ -24,4 +36,4 @@
|
||||
#### 06/11/14
|
||||
|
||||
|
||||
**This file was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
||||
\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
||||
@@ -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'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "github_changelog_generator"
|
||||
s.version = "1.0.1"
|
||||
s.version = "1.1.1"
|
||||
s.default_executable = "github_changelog_generator"
|
||||
|
||||
s.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
@@ -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)
|
||||
@@ -80,12 +80,7 @@ class ChangelogGenerator
|
||||
log += self.generate_log_for_all_tags
|
||||
end
|
||||
|
||||
|
||||
if @options[:verbose]
|
||||
puts log
|
||||
end
|
||||
|
||||
log += "\n\n* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||
log += "\n\n\\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||
|
||||
output_filename = "#{@options[:output]}"
|
||||
File.open(output_filename, 'w') { |file| file.write(log) }
|
||||
@@ -117,9 +112,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 +160,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 +196,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
|
||||
@@ -223,7 +223,7 @@ class ChangelogGenerator
|
||||
# Generate pull requests:
|
||||
if pull_requests
|
||||
pull_requests.each { |dict|
|
||||
merge = "#{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/pull/#{dict[:number]})\n\n"
|
||||
merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
|
||||
log += "- #{merge}"
|
||||
}
|
||||
end
|
||||
@@ -232,34 +232,47 @@ class ChangelogGenerator
|
||||
if @options[:issues]
|
||||
# Generate issues:
|
||||
if issues
|
||||
issues.each { |dict|
|
||||
is_bug = false
|
||||
is_enhancement = false
|
||||
dict.labels.each { |label|
|
||||
if label.name == 'bug'
|
||||
is_bug = true
|
||||
issues.sort! { |x, y|
|
||||
if x.labels.any? && y.labels.any?
|
||||
x.labels[0].name <=> y.labels[0].name
|
||||
else
|
||||
if x.labels.any?
|
||||
1
|
||||
else
|
||||
if y.labels.any?
|
||||
-1
|
||||
else
|
||||
0
|
||||
end
|
||||
end
|
||||
if label.name == 'enhancement'
|
||||
is_enhancement = true
|
||||
end
|
||||
}
|
||||
|
||||
intro = 'Closed issue'
|
||||
if is_bug
|
||||
intro = 'Fixed bug'
|
||||
end
|
||||
|
||||
if is_enhancement
|
||||
intro = 'Implemented enhancement'
|
||||
end
|
||||
|
||||
merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/issues/#{dict[:number]})\n\n"
|
||||
log += "- #{merge}"
|
||||
}
|
||||
}.reverse!
|
||||
end
|
||||
issues.each { |dict|
|
||||
is_bug = false
|
||||
is_enhancement = false
|
||||
dict.labels.each { |label|
|
||||
if label.name == 'bug'
|
||||
is_bug = true
|
||||
end
|
||||
if label.name == 'enhancement'
|
||||
is_enhancement = true
|
||||
end
|
||||
}
|
||||
|
||||
intro = 'Closed issue'
|
||||
if is_bug
|
||||
intro = 'Fixed bug'
|
||||
end
|
||||
|
||||
if is_enhancement
|
||||
intro = 'Implemented enhancement'
|
||||
end
|
||||
|
||||
merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
|
||||
log += "- #{merge}"
|
||||
}
|
||||
end
|
||||
|
||||
log
|
||||
end
|
||||
|
||||
@@ -281,15 +294,31 @@ class ChangelogGenerator
|
||||
|
||||
def get_all_issues
|
||||
all_issues = []
|
||||
@options[:labels].each { |label|
|
||||
issues = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: label
|
||||
all_issues = all_issues.concat(issues.body)
|
||||
|
||||
issues_req = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
|
||||
|
||||
filtered_issues = issues_req.body.select { |issues|
|
||||
#compare is there any labels from @options[:labels] array
|
||||
(issues.labels.map { |issue| issue.name } & @options[:labels]).any?
|
||||
}
|
||||
|
||||
if @options[:add_issues_wo_labels]
|
||||
issues_wo_labels = issues_req.body.select {
|
||||
|issues| !issues.labels.map { |issue| issue.name }.any?
|
||||
}
|
||||
filtered_issues.concat(issues_wo_labels)
|
||||
end
|
||||
|
||||
# remove pull request from issues:
|
||||
filtered_issues.select! { |x|
|
||||
x.pull_request == nil
|
||||
}
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Receive all closed issues with labels #{@options[:labels]}: #{all_issues.count} issues"
|
||||
end
|
||||
|
||||
all_issues
|
||||
filtered_issues
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -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, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ' }
|
||||
|
||||
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|
|
||||
@@ -20,12 +20,15 @@ class Parser
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
|
||||
opts.on('-v', '--[no-]verbose', 'Run verbosely. Default is true') do |v|
|
||||
options[:verbose] = v
|
||||
end
|
||||
opts.on('--[no-]issues', 'Include closed issues to changelog. Default is true') do |v|
|
||||
options[:issues] = v
|
||||
end
|
||||
opts.on('--[no-]issues-without-labels', 'Include closed issues without any labels to changelog. Default is true') do |v|
|
||||
options[:add_issues_wo_labels] = v
|
||||
end
|
||||
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
|
||||
options[:pulls] = v
|
||||
end
|
||||
@@ -51,6 +54,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
|
||||
|
||||
Reference in New Issue
Block a user