Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b44c4aa78 | ||
|
|
95bdd60c34 | ||
|
|
1357b3980d | ||
|
|
b30587ce14 | ||
|
|
18e0f937ea | ||
|
|
1af8e18f9f | ||
|
|
a458a1e378 | ||
|
|
bc3af7fa93 | ||
|
|
6682ffe452 | ||
|
|
dbc7b3e567 | ||
|
|
a96f74208c | ||
|
|
cdc009b4ad | ||
|
|
0046f344a9 | ||
|
|
1b792bc67b | ||
|
|
f0716771b5 | ||
|
|
50dd7b2ed6 | ||
|
|
3797b3ac31 | ||
|
|
f08685b015 | ||
|
|
fc96007741 |
38
CHANGELOG.md
38
CHANGELOG.md
@@ -1,22 +1,42 @@
|
||||
# Changelog
|
||||
|
||||
## [1.1.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.1)
|
||||
#### 10/11/14
|
||||
- *Merged pull-request:* Remove duplicates of issues and pull-requests with same number [\#15](https://github.com/skywinder/Github-Changelog-Generator/pull/15)
|
||||
|
||||
- *Merged pull-request:* Sort issues by tags [\#14](https://github.com/skywinder/Github-Changelog-Generator/pull/14)
|
||||
|
||||
- *Merged pull-request:* Add ability to add or exclude issues without any labels [\#13](https://github.com/skywinder/Github-Changelog-Generator/pull/13)
|
||||
|
||||
## [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 +44,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)*
|
||||
62
README.md
62
README.md
@@ -11,48 +11,56 @@ This script automatically generate change-log from your tags and merged pull-req
|
||||
[sudo] gem install github_changelog_generator
|
||||
|
||||
## Usage
|
||||
**It's really simple**:
|
||||
|
||||
github_changelog_generator -u github-username -p github-project
|
||||
- `cd` to your Project folder with configured git and just type:
|
||||
|
||||
In output you will get `CHANGELOG.md` file with *pretty Markdown-formatted* changelogs in your current directory.
|
||||
github_changelog_generator
|
||||
|
||||
### Params:
|
||||
See `github_changelog_generator --help` for detailed usage.
|
||||
- from anywhere:
|
||||
|
||||
Usage: changelog_generator --user username --project project_name [options]
|
||||
-u, --user [USER] Username of the owner of target GitHub repo (required)
|
||||
-p, --project [PROJECT] Name of project on GitHub (required)
|
||||
-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
|
||||
-h, --help Displays Help
|
||||
-v, --[no-]verbose Run verbosely
|
||||
--[no-]issues Include closed issues to changelog. Default is true
|
||||
--[no-]pull-requests Include pull-requests to changelog. Default is true
|
||||
-l, --last-changes Generate log between last 2 tags only
|
||||
-f, --date-format [FORMAT] Date format. Default is %d/%m/%y
|
||||
-o, --output [NAME] Output file. Default is CHANGELOG.md
|
||||
--labels x,y,z List of labels. Issues with that labels will be included to changelog. Default is 'bug,enhancement'a
|
||||
github_changelog_generator -u github-username -p github-project
|
||||
|
||||
As output you will get `CHANGELOG.md` file with *pretty Markdown-formatted* changelog.
|
||||
|
||||
## Params:
|
||||
Type `github_changelog_generator --help` for detailed usage.
|
||||
|
||||
Usage: changelog_generator [options]
|
||||
-u, --user [USER] Username of the owner of target GitHub repo
|
||||
-p, --project [PROJECT] Name of project on GitHub
|
||||
-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
|
||||
-h, --help Displays Help
|
||||
-v, --[no-]verbose Run verbosely. Default is true
|
||||
--[no-]issues Include closed issues to changelog. Default is true
|
||||
--[no-]issues-without-labels Include closed issues without any labels to changelog. Default is true
|
||||
--[no-]pull-requests Include pull-requests to changelog. Default is true
|
||||
-l, --last-changes Generate log between last 2 tags only
|
||||
-f, --date-format [FORMAT] Date format. Default is %d/%m/%y
|
||||
-o, --output [NAME] Output file. Default is CHANGELOG.md
|
||||
--labels x,y,z List of labels. Issues with that labels will be included to changelog. Default is 'bug,enhancement'
|
||||
|
||||
## Examples:
|
||||
Look at changelog in this project!
|
||||
|
||||
### This changelog: [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md)
|
||||
- Look at changelog for **[CHANGELOG.md](https://github.com/skywinder/Github-Changelog-Generator/blob/master/CHANGELOG.md)** for this project
|
||||
- This changelog: [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by command:
|
||||
|
||||
Was generated by command:
|
||||
|
||||
github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
|
||||
github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
|
||||
|
||||
|
||||
## FAQ:
|
||||
Since GitHub allow to make only 50 requests without authentication it's recommended to run this scrip with key `-t [your-16-digit-token]` that you can easily **[generate it here](https://github.com/settings/applications)**.
|
||||
|
||||
So, if you got error like this:
|
||||
>! /Library/Ruby/Gems/2.0.0/gems/github_api-0.12.2/lib/github_api/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/skywinder/ActionSheetPicker-3.0/git/commits/89678f7d7f66873c858e6cb07bf697192aca6768: 403 API rate limit exceeded for 195.88.177.9. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) (Github::Error::Forbidden)
|
||||
>! /Library/Ruby/Gems/2.0.0/gems/github_api-0.12.2/lib/github_api/response/raise_error.rb:14:in `on_complete'
|
||||
|
||||
It's time to generate this token or wait for 1 hour before GitHub reset counter for your IP.
|
||||
It's time to create this token or wait for 1 hour before GitHub reset the counter for your IP.
|
||||
|
||||
## License
|
||||
## Am I missed some essential feature?
|
||||
|
||||
Github the Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
||||
**Nothing is impossible!** Open an [issue](https://github.com/skywinder/Github-Changelog-Generator/issues/new) and let's get this generator better together!
|
||||
|
||||
*Bug reports, feature requests, patches, well-wishes are always welcome!*
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -63,6 +71,6 @@ Github the Generator is released under the [MIT License](http://www.opensource.o
|
||||
5. Push to the branch (`git push origin my-new-feature`)
|
||||
6. Create a new Pull Request
|
||||
|
||||
**Bug reports, feature requests, patches, well-wishes, and rap demo tapes are always welcome!**
|
||||
## License
|
||||
|
||||
*Improvements more than welcome - they are kindly requested! :)*
|
||||
Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "github_changelog_generator"
|
||||
s.version = "1.1.0"
|
||||
s.version = "1.1.2"
|
||||
s.default_executable = "github_changelog_generator"
|
||||
|
||||
s.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
@@ -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) }
|
||||
@@ -228,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
|
||||
@@ -237,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
|
||||
|
||||
@@ -286,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,7 +3,7 @@ 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, :verbose => 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 [options]'
|
||||
@@ -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
|
||||
@@ -53,9 +56,9 @@ class Parser
|
||||
|
||||
if !options[:user] && !options[:project]
|
||||
remote = `git remote -vv`.split("\n")
|
||||
match = /.*(?:[:\/])(\w*)\/((?:-|\w)*)\.git.*/.match(remote[0])
|
||||
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)\.git.*/.match(remote[0])
|
||||
|
||||
if match[1] && match[2]
|
||||
if match && match[1] && match[2]
|
||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||
options[:user], options[:project] = match[1], match[2]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user