Merge branch 'new-features'

This commit is contained in:
Petr Korolev 2014-11-07 11:29:36 +02:00
commit e2aac3cb2c
3 changed files with 26 additions and 20 deletions

View File

@ -6,32 +6,34 @@ Github Changelog Generator
This script automatically generate change-log from your tags and merged pull-requests.
## Installation:
`gem install github_changelog_generator`
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
## 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)**.
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)

View File

@ -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}"

View File

@ -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!