diff --git a/README.md b/README.md index 73d23b2e7..71c8c064a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/github_changelog_generator.gemspec b/github_changelog_generator.gemspec index 2d040ef88..1e067fc58 100644 --- a/github_changelog_generator.gemspec +++ b/github_changelog_generator.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |s| s.name = "github_changelog_generator" - s.version = "0.0.1" + s.version = "0.0.2" s.default_executable = "github_changelog_generator" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.required_ruby_version = '>= 1.9.3' s.authors = ["Petr Korolev"] s.date = %q{2014-10-10} s.description = %q{Script, that automatically generate change-log from your tags and pull-requests} @@ -14,8 +14,7 @@ Gem::Specification.new do |s| s.rubygems_version = %q{1.6.2} s.summary = %q{Script, that automatically generate change-log from your tags and pull-requests.} s.license = "MIT" - - s.add_runtime_dependency(%q, ["~> 0.6"]) + s.add_runtime_dependency(%q, ["~> 0.13"]) s.add_runtime_dependency(%q, ["~> 0.12"]) s.executables = %w(github_changelog_generator) diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 19ceed911..6aa2a563b 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -87,7 +87,9 @@ def compund_changelog puts log end - output_filename = "#{@options[:project]}_changelog.md" + log += "\n\n*This file 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) } puts "Done! Generated log placed in #{output_filename}" diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 534c7e9f8..0dc882a0d 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -3,17 +3,17 @@ 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 @@ def self.parse_options 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!