Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24c5f66c65 | ||
|
|
9c4b68f779 | ||
|
|
65e978f4a8 | ||
|
|
6b4333f98a | ||
|
|
675601880d | ||
|
|
e2aac3cb2c | ||
|
|
20095c571d |
47
README.md
47
README.md
@@ -1,46 +1,53 @@
|
||||
Github Changelog Generator
|
||||
GitHub Changelog Generator
|
||||
==================
|
||||
|
||||
[](http://badge.fury.io/rb/github_changelog_generator)
|
||||
|
||||
Changelog generation has never been so easy.
|
||||
|
||||
This script automatically generate change-log from your tags and merged pull-requests.
|
||||
|
||||
## Installation:
|
||||
`gem install github_changelog_generator`
|
||||
[sudo] gem install github_changelog_generator
|
||||
|
||||
## Usage:
|
||||
## Usage
|
||||
|
||||
### Example usage:
|
||||
`github_changelog_generator -u github-username -p github-project`
|
||||
github_changelog_generator -u github-username -p github-project
|
||||
|
||||
In output you will get `[your_project]_CHANGELOG.md` file with *pretty Markdown-formatted* changelogs in your current directory.
|
||||
In output you will get `CHANGELOG.md` file with *pretty Markdown-formatted* changelogs in your current directory.
|
||||
|
||||
### Params:
|
||||
github_changelog_generator -u user_name -p project_name [-t 16-digit-GitHubToken] [options]
|
||||
-u, --user [USER] your username on GitHub
|
||||
-p, --project [PROJECT] name of project on GitHub
|
||||
-t, --token [TOKEN] To make more than 50 requests this app required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications
|
||||
See `github_changelog_generator --help` for detailed usage.
|
||||
|
||||
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
|
||||
-l, --last-changes generate log between last 2 tags
|
||||
-f, --date-format [FORMAT] date format. default is %d/%m/%y
|
||||
-l, --last-changes Generate log between only last 2 tags
|
||||
-f, --date-format [FORMAT] Date format. Default is %d/%m/%y
|
||||
-o, --output [FORMAT] Output file. Default is CHANGELOG.md
|
||||
|
||||
## Examples:
|
||||
### This changelog: [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md)
|
||||
|
||||
Was generated by command:
|
||||
|
||||
github_changelog_generator -u skywinder -p ActionSheetPicker-3.0
|
||||
|
||||
|
||||
## Real examples:
|
||||
### [This changelog](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by
|
||||
`github_changelog_generator -u skywinder -p ActionSheetPicker-3.0`: [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md)
|
||||
|
||||
## 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 here](https://github.com/settings/applications)**.
|
||||
## 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)
|
||||
|
||||
Then you have to generate this token or wait for 1 hour
|
||||
It's time to generate this token or wait for 1 hour before GitHub reset counter for your IP.
|
||||
|
||||
## License
|
||||
|
||||
Github Changelog Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
||||
Github the Generator is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -88,7 +88,8 @@ class ChangelogGenerator
|
||||
end
|
||||
|
||||
log += "\n\n*This file was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"
|
||||
output_filename = "#{@options[:project]}_CHANGELOG.md"
|
||||
|
||||
output_filename = "#{@options[:output]}"
|
||||
File.open(output_filename, 'w') { |file| file.write(log) }
|
||||
|
||||
puts "Done! Generated log placed in #{output_filename}"
|
||||
@@ -101,6 +102,8 @@ class ChangelogGenerator
|
||||
log += self.generate_log_between_tags(self.all_tags[index-1], self.all_tags[index])
|
||||
end
|
||||
|
||||
log += self.generate_log_before_tag(self.all_tags.last)
|
||||
|
||||
log
|
||||
end
|
||||
|
||||
@@ -157,17 +160,32 @@ class ChangelogGenerator
|
||||
pull_requests = Array.new(@pull_requests)
|
||||
|
||||
pull_requests.delete_if { |req|
|
||||
t = Time.parse(req[:closed_at]).utc
|
||||
true_classor_false_class = t > since_tag_time
|
||||
classor_false_class = t < till_tag_time
|
||||
t = Time.parse(req[:merged_at]).utc
|
||||
tag_is_later_since = t > since_tag_time
|
||||
tag_is_before_till = t <= till_tag_time
|
||||
|
||||
in_range = (true_classor_false_class) && (classor_false_class)
|
||||
in_range = (tag_is_later_since) && (tag_is_before_till)
|
||||
!in_range
|
||||
}
|
||||
|
||||
self.create_log(pull_requests, till_tag_name, till_tag_time)
|
||||
end
|
||||
|
||||
def generate_log_before_tag(tag)
|
||||
tag_time = self.get_time_of_tag(tag)
|
||||
tag_name = tag['name']
|
||||
|
||||
pull_requests = Array.new(@pull_requests)
|
||||
|
||||
pull_requests.delete_if { |req|
|
||||
t = Time.parse(req[:closed_at]).utc
|
||||
t > tag_time
|
||||
}
|
||||
|
||||
self.create_log(pull_requests, tag_name, tag_time)
|
||||
|
||||
end
|
||||
|
||||
def create_log(pull_requests, tag_name, tag_time)
|
||||
|
||||
trimmed_tag = tag_name.tr('v', '')
|
||||
|
||||
@@ -3,17 +3,17 @@ require 'optparse'
|
||||
|
||||
class Parser
|
||||
def self.parse_options
|
||||
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y'}
|
||||
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md'}
|
||||
|
||||
parser = OptionParser.new { |opts|
|
||||
opts.banner = 'Usage: changelog_generator -u user_name -p project_name [-t 16-digit-GitHubToken] [options]'
|
||||
opts.on('-u', '--user [USER]', 'your username on GitHub') do |last|
|
||||
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|
|
||||
options[:user] = last
|
||||
end
|
||||
opts.on('-p', '--project [PROJECT]', 'name of project on GitHub') do |last|
|
||||
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub (required)') do |last|
|
||||
options[:project] = last
|
||||
end
|
||||
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this app 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|
|
||||
options[:token] = last
|
||||
end
|
||||
opts.on('-h', '--help', 'Displays Help') do
|
||||
@@ -23,12 +23,15 @@ class Parser
|
||||
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
|
||||
options[:verbose] = v
|
||||
end
|
||||
opts.on('-l', '--last-changes', 'generate log between last 2 tags') do |last|
|
||||
opts.on('-l', '--last-changes', 'Generate log between only last 2 tags') do |last|
|
||||
options[:last] = last
|
||||
end
|
||||
opts.on('-f', '--date-format [FORMAT]', 'date format. default is %d/%m/%y') do |last|
|
||||
opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
|
||||
options[:format] = last
|
||||
end
|
||||
opts.on('-o', '--output [FORMAT]', 'Output file. Default is CHANGELOG.md') do |last|
|
||||
options[:output] = last
|
||||
end
|
||||
}
|
||||
|
||||
parser.parse!
|
||||
|
||||
Reference in New Issue
Block a user