Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b08f881fb1 | ||
|
|
7388ca8581 | ||
|
|
4c7df83a4c | ||
|
|
059e4d4bc3 | ||
|
|
6c2ef97f63 | ||
|
|
226748d8ff | ||
|
|
74882ef900 | ||
|
|
37a7430d81 | ||
|
|
939f6fd768 | ||
|
|
f32a02a75b | ||
|
|
430d6f5bd9 | ||
|
|
4f57845465 | ||
|
|
4969108eca | ||
|
|
c0c8bb5653 | ||
|
|
fdd41a22f6 | ||
|
|
08c3d9f913 | ||
|
|
1c48f633d8 | ||
|
|
f6fcac7aff | ||
|
|
074320d925 | ||
|
|
bb87462e3a | ||
|
|
9acfcf103c | ||
|
|
25c7856e19 | ||
|
|
49f8df24aa | ||
|
|
408b12111d | ||
|
|
f169ea688e | ||
|
|
a3b32ca2df | ||
|
|
55fba0f479 | ||
|
|
d13d22eb01 | ||
|
|
c2083a4df5 | ||
|
|
0c2e62954d | ||
|
|
f09a6183a4 | ||
|
|
3962474e9f | ||
|
|
58bfa047c4 | ||
|
|
59db1c7821 | ||
|
|
0e671a96da | ||
|
|
4c737c9373 | ||
|
|
df31f98ce3 | ||
|
|
b63d9d623e | ||
|
|
d9e2cdeeac | ||
|
|
8bd4578e44 | ||
|
|
9483c5edcb | ||
|
|
ac06e8bffe | ||
|
|
e66242794b | ||
|
|
c2fd582c2d | ||
|
|
0f5562264c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -5,3 +5,5 @@ pkg/
|
|||||||
coverage/
|
coverage/
|
||||||
.bundle
|
.bundle
|
||||||
spec/*.lock
|
spec/*.lock
|
||||||
|
doc
|
||||||
|
.yardoc
|
||||||
|
|||||||
53
CHANGELOG.md
53
CHANGELOG.md
@@ -1,5 +1,54 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [1.13.1](https://github.com/skywinder/github-changelog-generator/tree/1.13.1) (2016-07-22)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.13.0...1.13.1)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Don't constrain runtime deps. [\#400](https://github.com/skywinder/github-changelog-generator/pull/400) ([jkeiser](https://github.com/jkeiser))
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- `--user` flag should not be ignored [\#397](https://github.com/skywinder/github-changelog-generator/issues/397)
|
||||||
|
- GHE not working with --github-site set to an enterprise site [\#395](https://github.com/skywinder/github-changelog-generator/issues/395)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Contributors Section [\#398](https://github.com/skywinder/github-changelog-generator/issues/398)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Ability to implicity set user and project from command line [\#401](https://github.com/skywinder/github-changelog-generator/pull/401) ([skywinder](https://github.com/skywinder))
|
||||||
|
- Show how to use it with Rakefile [\#399](https://github.com/skywinder/github-changelog-generator/pull/399) ([edusantana](https://github.com/edusantana))
|
||||||
|
- Adds documentation on using a GHE endpoint [\#396](https://github.com/skywinder/github-changelog-generator/pull/396) ([cormacmccarthy](https://github.com/cormacmccarthy))
|
||||||
|
- Rake task usage: Added a missing option exclude\_tags\_regex [\#393](https://github.com/skywinder/github-changelog-generator/pull/393) ([perlun](https://github.com/perlun))
|
||||||
|
- Parser: YARD docstrings and a rename, and RegExp named capture groups [\#391](https://github.com/skywinder/github-changelog-generator/pull/391) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
## [1.13.0](https://github.com/skywinder/github-changelog-generator/tree/1.13.0) (2016-07-04)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.12.1...1.13.0)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Carry PR \#301: usernames\_as\_github\_logins [\#392](https://github.com/skywinder/github-changelog-generator/pull/392) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
## [1.12.1](https://github.com/skywinder/github-changelog-generator/tree/1.12.1) (2016-05-09)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.12.0...1.12.1)
|
||||||
|
|
||||||
|
**Fixed bugs:**
|
||||||
|
|
||||||
|
- github\_changelog\_generator/generator/generator\_tags.rb:61:in `detect\_since\_tag': undefined method `\[\]' for nil:NilClass \(NoMethodError\) [\#351](https://github.com/skywinder/github-changelog-generator/issues/351)
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- Add a LICENSE file [\#369](https://github.com/skywinder/github-changelog-generator/issues/369)
|
||||||
|
- Error installing on Ubuntu 14.04 [\#364](https://github.com/skywinder/github-changelog-generator/issues/364)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Move dev gems to add\_development\_dependency [\#373](https://github.com/skywinder/github-changelog-generator/pull/373) ([skywinder](https://github.com/skywinder))
|
||||||
|
- Add MIT LICENSE file [\#370](https://github.com/skywinder/github-changelog-generator/pull/370) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Avoid nil bug in detect\_since\_tag [\#368](https://github.com/skywinder/github-changelog-generator/pull/368) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
## [1.12.0](https://github.com/skywinder/github-changelog-generator/tree/1.12.0) (2016-04-01)
|
## [1.12.0](https://github.com/skywinder/github-changelog-generator/tree/1.12.0) (2016-04-01)
|
||||||
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.8...1.12.0)
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.11.8...1.12.0)
|
||||||
|
|
||||||
@@ -491,10 +540,6 @@
|
|||||||
|
|
||||||
- Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/github-changelog-generator/issues/34)
|
- Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/github-changelog-generator/issues/34)
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/github-changelog-generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
|
|
||||||
|
|
||||||
## [1.2.1](https://github.com/skywinder/github-changelog-generator/tree/1.2.1) (2014-11-22)
|
## [1.2.1](https://github.com/skywinder/github-changelog-generator/tree/1.2.1) (2014-11-22)
|
||||||
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.2.0...1.2.1)
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.2.0...1.2.1)
|
||||||
|
|
||||||
|
|||||||
2
Gemfile
2
Gemfile
@@ -10,4 +10,6 @@ group :test do
|
|||||||
gem "coveralls", "~>0.8", require: false
|
gem "coveralls", "~>0.8", require: false
|
||||||
gem "simplecov", "~>0.10", require: false
|
gem "simplecov", "~>0.10", require: false
|
||||||
gem "codeclimate-test-reporter", "~>0.4"
|
gem "codeclimate-test-reporter", "~>0.4"
|
||||||
|
# JSON 2.0.1 is ruby 2.0+
|
||||||
|
gem "json", "< 2.0"
|
||||||
end
|
end
|
||||||
|
|||||||
78
Gemfile.lock
78
Gemfile.lock
@@ -1,24 +1,24 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
github_changelog_generator (1.12.0)
|
github_changelog_generator (1.13.1)
|
||||||
colorize (~> 0.7)
|
colorize (>= 0.7)
|
||||||
github_api (~> 0.12)
|
github_api (>= 0.12)
|
||||||
rake (>= 10.0)
|
rake (>= 10.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.4.0)
|
addressable (2.4.0)
|
||||||
ast (2.2.0)
|
ast (2.3.0)
|
||||||
childprocess (0.5.9)
|
childprocess (0.5.9)
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
ffi (~> 1.0, >= 1.0.11)
|
||||||
codeclimate-test-reporter (0.5.0)
|
codeclimate-test-reporter (0.6.0)
|
||||||
simplecov (>= 0.7.1, < 1.0.0)
|
simplecov (>= 0.7.1, < 1.0.0)
|
||||||
colorize (0.7.7)
|
colorize (0.8.1)
|
||||||
coveralls (0.8.13)
|
coveralls (0.8.14)
|
||||||
json (~> 1.8)
|
json (>= 1.8, < 3)
|
||||||
simplecov (~> 0.11.0)
|
simplecov (~> 0.12.0)
|
||||||
term-ansicolor (~> 1.3)
|
term-ansicolor (~> 1.3)
|
||||||
thor (~> 0.19.1)
|
thor (~> 0.19.1)
|
||||||
tins (~> 1.6.0)
|
tins (~> 1.6.0)
|
||||||
@@ -28,59 +28,58 @@ GEM
|
|||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
faraday (0.9.2)
|
faraday (0.9.2)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.9.10)
|
ffi (1.9.14)
|
||||||
github_api (0.13.1)
|
github_api (0.14.4)
|
||||||
addressable (~> 2.4.0)
|
addressable (~> 2.4.0)
|
||||||
descendants_tracker (~> 0.0.4)
|
descendants_tracker (~> 0.0.4)
|
||||||
faraday (~> 0.8, < 0.10)
|
faraday (~> 0.8, < 0.10)
|
||||||
hashie (>= 3.4)
|
hashie (>= 3.4)
|
||||||
multi_json (>= 1.7.5, < 2.0)
|
oauth2 (~> 1.0.0)
|
||||||
oauth2
|
|
||||||
hashie (3.4.4)
|
hashie (3.4.4)
|
||||||
iniparse (1.4.2)
|
iniparse (1.4.2)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
jwt (1.5.1)
|
jwt (1.5.4)
|
||||||
multi_json (1.12.0)
|
multi_json (1.12.1)
|
||||||
multi_xml (0.5.5)
|
multi_xml (0.5.5)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
oauth2 (1.1.0)
|
oauth2 (1.0.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
faraday (>= 0.8, < 0.10)
|
||||||
jwt (~> 1.0, < 1.5.2)
|
jwt (~> 1.0)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
multi_xml (~> 0.5)
|
multi_xml (~> 0.5)
|
||||||
rack (>= 1.2, < 3)
|
rack (~> 1.2)
|
||||||
overcommit (0.33.0)
|
overcommit (0.34.2)
|
||||||
childprocess (~> 0.5.8)
|
childprocess (~> 0.5.8)
|
||||||
iniparse (~> 1.4)
|
iniparse (~> 1.4)
|
||||||
parser (2.3.1.0)
|
parser (2.3.1.2)
|
||||||
ast (~> 2.2)
|
ast (~> 2.2)
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
rack (1.6.4)
|
rack (1.6.4)
|
||||||
rainbow (2.1.0)
|
rainbow (2.1.0)
|
||||||
rake (11.1.2)
|
rake (11.2.2)
|
||||||
rspec (3.4.0)
|
rspec (3.5.0)
|
||||||
rspec-core (~> 3.4.0)
|
rspec-core (~> 3.5.0)
|
||||||
rspec-expectations (~> 3.4.0)
|
rspec-expectations (~> 3.5.0)
|
||||||
rspec-mocks (~> 3.4.0)
|
rspec-mocks (~> 3.5.0)
|
||||||
rspec-core (3.4.4)
|
rspec-core (3.5.1)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.5.0)
|
||||||
rspec-expectations (3.4.0)
|
rspec-expectations (3.5.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.5.0)
|
||||||
rspec-mocks (3.4.1)
|
rspec-mocks (3.5.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.4.0)
|
rspec-support (~> 3.5.0)
|
||||||
rspec-support (3.4.1)
|
rspec-support (3.5.0)
|
||||||
rubocop (0.39.0)
|
rubocop (0.41.2)
|
||||||
parser (>= 2.3.0.7, < 3.0)
|
parser (>= 2.3.1.1, < 3.0)
|
||||||
powerpack (~> 0.1)
|
powerpack (~> 0.1)
|
||||||
rainbow (>= 1.99.1, < 3.0)
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||||
ruby-progressbar (1.8.0)
|
ruby-progressbar (1.8.1)
|
||||||
simplecov (0.11.2)
|
simplecov (0.12.0)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
json (~> 1.8)
|
json (>= 1.8, < 3)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
simplecov-html (0.10.0)
|
simplecov-html (0.10.0)
|
||||||
term-ansicolor (1.3.2)
|
term-ansicolor (1.3.2)
|
||||||
@@ -88,7 +87,7 @@ GEM
|
|||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tins (1.6.0)
|
tins (1.6.0)
|
||||||
unicode-display_width (1.0.5)
|
unicode-display_width (1.1.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@@ -98,6 +97,7 @@ DEPENDENCIES
|
|||||||
codeclimate-test-reporter (~> 0.4)
|
codeclimate-test-reporter (~> 0.4)
|
||||||
coveralls (~> 0.8)
|
coveralls (~> 0.8)
|
||||||
github_changelog_generator!
|
github_changelog_generator!
|
||||||
|
json (< 2.0)
|
||||||
overcommit
|
overcommit
|
||||||
rake
|
rake
|
||||||
rspec (>= 3.2)
|
rspec (>= 3.2)
|
||||||
@@ -105,4 +105,4 @@ DEPENDENCIES
|
|||||||
simplecov (~> 0.10)
|
simplecov (~> 0.10)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.11.2
|
1.12.5
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ Because software tools are for people. If you don’t care, why are you contribu
|
|||||||
- `github_changelog_generator -u github_username -p github_project`
|
- `github_changelog_generator -u github_username -p github_project`
|
||||||
- `github_changelog_generator github_username/github_project`
|
- `github_changelog_generator github_username/github_project`
|
||||||
|
|
||||||
|
- If you are running it against a repository on a Github Enterprise install, you must specify *both* `--github-site` and `--github-api` command line options:
|
||||||
|
|
||||||
|
github_changelog_generator --github-site="https://github.yoursite.com" \
|
||||||
|
--github-api="https://github.yoursite.com/api/v3/"
|
||||||
|
|
||||||
This generates a changelog to the `CHANGELOG.md` file, with pretty markdown formatting.
|
This generates a changelog to the `CHANGELOG.md` file, with pretty markdown formatting.
|
||||||
|
|
||||||
### Params
|
### Params
|
||||||
@@ -133,6 +138,8 @@ we've provided a `rake` task library for your changelog generation.
|
|||||||
Just put something like this in your `Rakefile`:
|
Just put something like this in your `Rakefile`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
|
require 'github_changelog_generator/task'
|
||||||
|
|
||||||
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
||||||
config.since_tag = '0.1.14'
|
config.since_tag = '0.1.14'
|
||||||
config.future_release = '0.2.0'
|
config.future_release = '0.2.0'
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ Gem::Specification.new do |spec|
|
|||||||
spec.require_paths = ["lib"]
|
spec.require_paths = ["lib"]
|
||||||
|
|
||||||
spec.add_runtime_dependency "rake", ">= 10.0"
|
spec.add_runtime_dependency "rake", ">= 10.0"
|
||||||
spec.add_runtime_dependency("github_api", ["~> 0.12"])
|
spec.add_runtime_dependency "github_api", ">= 0.12"
|
||||||
spec.add_runtime_dependency("colorize", ["~> 0.7"])
|
spec.add_runtime_dependency "colorize", ">= 0.7"
|
||||||
|
|
||||||
spec.add_development_dependency("overcommit", ">= 0.31")
|
spec.add_development_dependency "overcommit", ">= 0.31"
|
||||||
spec.add_development_dependency("rspec", ">= 3.2")
|
spec.add_development_dependency "rspec", ">= 3.2"
|
||||||
spec.add_development_dependency "bundler", ">= 1.7"
|
spec.add_development_dependency "bundler", ">= 1.7"
|
||||||
spec.add_development_dependency("rubocop", ">= 0.31")
|
spec.add_development_dependency "rubocop", ">= 0.31"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ module GitHubChangelogGenerator
|
|||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
page_i += PER_PAGE_NUMBER
|
page_i += PER_PAGE_NUMBER
|
||||||
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
|
||||||
tags.concat(page)
|
tags.concat(page) unless page.nil?
|
||||||
end
|
end
|
||||||
print_empty_line
|
print_empty_line
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ module GitHubChangelogGenerator
|
|||||||
# Parse issue and generate single line formatted issue line.
|
# Parse issue and generate single line formatted issue line.
|
||||||
#
|
#
|
||||||
# Example output:
|
# Example output:
|
||||||
# - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) ([skywinder](https://github.com/skywinder))
|
# - Add coveralls integration [\#223](https://github.com/skywinder/github-changelog-generator/pull/223) (@skywinder)
|
||||||
#
|
#
|
||||||
# @param [Hash] issue Fetched issue from GitHub
|
# @param [Hash] issue Fetched issue from GitHub
|
||||||
# @return [String] Markdown-formatted single issue
|
# @return [String] Markdown-formatted single issue
|
||||||
@@ -168,17 +168,22 @@ module GitHubChangelogGenerator
|
|||||||
encapsulated_title = encapsulate_string issue[:title]
|
encapsulated_title = encapsulate_string issue[:title]
|
||||||
|
|
||||||
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
|
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
|
||||||
|
issue_line_with_user(title_with_number, issue)
|
||||||
|
end
|
||||||
|
|
||||||
unless issue.pull_request.nil?
|
private
|
||||||
if @options[:author]
|
|
||||||
title_with_number += if issue.user.nil?
|
def issue_line_with_user(line, issue)
|
||||||
" ({Null user})"
|
return line if !@options[:author] || issue.pull_request.nil?
|
||||||
|
|
||||||
|
user = issue.user
|
||||||
|
return "#{line} ({Null user})" unless user
|
||||||
|
|
||||||
|
if @options[:usernames_as_github_logins]
|
||||||
|
"#{line} (@#{user.login})"
|
||||||
else
|
else
|
||||||
" ([#{issue.user.login}](#{issue.user.html_url}))"
|
"#{line} ([#{user.login}](#{user.html_url}))"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
title_with_number
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
106
lib/github_changelog_generator/parser.rb
Normal file → Executable file
106
lib/github_changelog_generator/parser.rb
Normal file → Executable file
@@ -14,7 +14,7 @@ module GitHubChangelogGenerator
|
|||||||
parser = setup_parser(options)
|
parser = setup_parser(options)
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
user_and_project_from_git(options)
|
fetch_user_and_project(options)
|
||||||
|
|
||||||
abort(parser.banner) unless options[:user] && options[:project]
|
abort(parser.banner) unless options[:user] && options[:project]
|
||||||
|
|
||||||
@@ -23,7 +23,12 @@ module GitHubChangelogGenerator
|
|||||||
options
|
options
|
||||||
end
|
end
|
||||||
|
|
||||||
# @param [Hash] options to display
|
# If options set to verbose, print the parsed options.
|
||||||
|
#
|
||||||
|
# The GitHub `:token` key is censored in the output.
|
||||||
|
#
|
||||||
|
# @param options [Hash] The options to display
|
||||||
|
# @option options [Boolean] :verbose If false this method does nothing
|
||||||
def self.print_options(options)
|
def self.print_options(options)
|
||||||
if options[:verbose]
|
if options[:verbose]
|
||||||
Helper.log.info "Performing task with options:"
|
Helper.log.info "Performing task with options:"
|
||||||
@@ -56,7 +61,7 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("-b", "--base [NAME]", "Optional base file to append generated changes to.") do |last|
|
opts.on("-b", "--base [NAME]", "Optional base file to append generated changes to.") do |last|
|
||||||
options[:base] = last
|
options[:base] = last
|
||||||
end
|
end
|
||||||
opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**""") do |v|
|
opts.on("--bugs-label [LABEL]", "Setup custom label for bug-fixes section. Default is \"**Fixed bugs:**\"") do |v|
|
||||||
options[:bug_prefix] = v
|
options[:bug_prefix] = v
|
||||||
end
|
end
|
||||||
opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v|
|
opts.on("--enhancement-label [LABEL]", "Setup custom label for enhancements section. Default is \"**Implemented enhancements:**\"") do |v|
|
||||||
@@ -92,6 +97,9 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("--[no-]author", "Add author of pull-request in the end. Default is true") do |author|
|
opts.on("--[no-]author", "Add author of pull-request in the end. Default is true") do |author|
|
||||||
options[:author] = author
|
options[:author] = author
|
||||||
end
|
end
|
||||||
|
opts.on("--usernames-as-github-logins", "Use GitHub tags instead of Markdown links for the author of an issue or pull-request.") do |v|
|
||||||
|
options[:usernames_as_github_logins] = v
|
||||||
|
end
|
||||||
opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
|
opts.on("--unreleased-only", "Generate log from unreleased closed issues only.") do |v|
|
||||||
options[:unreleased_only] = v
|
options[:unreleased_only] = v
|
||||||
end
|
end
|
||||||
@@ -167,7 +175,7 @@ module GitHubChangelogGenerator
|
|||||||
parser
|
parser
|
||||||
end
|
end
|
||||||
|
|
||||||
# just get default options
|
# @return [Hash] Default options
|
||||||
def self.default_options
|
def self.default_options
|
||||||
{
|
{
|
||||||
tag1: nil,
|
tag1: nil,
|
||||||
@@ -199,37 +207,54 @@ module GitHubChangelogGenerator
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.user_and_project_from_git(options)
|
# If `:user` or `:project` not set in options, try setting them
|
||||||
|
# Valid unnamed parameters:
|
||||||
|
# 1) in 1 param: repo_name/project
|
||||||
|
# 2) in 2 params: repo name project
|
||||||
|
def self.fetch_user_and_project(options)
|
||||||
if options[:user].nil? || options[:project].nil?
|
if options[:user].nil? || options[:project].nil?
|
||||||
detect_user_and_project(options, ARGV[0], ARGV[1])
|
user, project = user_and_project_from_git(options, ARGV[0], ARGV[1])
|
||||||
|
options[:user] ||= user
|
||||||
|
options[:project] ||= project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Detects user and project from git
|
# Sets `:user` and `:project` in `options` from CLI arguments or `git remote`
|
||||||
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
|
# @param [String] arg0 first argument in cli
|
||||||
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
|
# @param [String] arg1 second argument in cli
|
||||||
return if options[:user] && options[:project]
|
# @return [Array<String>] user and project, or nil if unsuccessful
|
||||||
|
def self.user_and_project_from_git(options, arg0 = nil, arg1 = nil)
|
||||||
|
user, project = user_project_from_option(arg0, arg1, options[:github_site])
|
||||||
|
unless user && project
|
||||||
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
||||||
options[:user] = "skywinder"
|
user = "skywinder"
|
||||||
options[:project] = "changelog_test"
|
project = "changelog_test"
|
||||||
else
|
else
|
||||||
remote = `git config --get remote.#{options[:git_remote]}.url`
|
remote = `git config --get remote.#{options[:git_remote]}.url`
|
||||||
options[:user], options[:project] = user_project_from_remote(remote)
|
user, project = user_project_from_remote(remote)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Try to find user and project name from git remote output
|
[user, project]
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns GitHub username and project from CLI arguments
|
||||||
#
|
#
|
||||||
# @param [String] output of git remote command
|
# @param arg0 [String] This parameter takes two forms: Either a full
|
||||||
# @return [Array] user and project
|
# GitHub URL, or a 'username/projectname', or
|
||||||
|
# simply a GitHub username
|
||||||
|
# @param arg1 [String] If arg0 is given as a username,
|
||||||
|
# then arg1 can given as a projectname
|
||||||
|
# @param github_site [String] Domain name of GitHub site
|
||||||
|
#
|
||||||
|
# @return [Array, nil] user and project, or nil if unsuccessful
|
||||||
def self.user_project_from_option(arg0, arg1, github_site)
|
def self.user_project_from_option(arg0, arg1, github_site)
|
||||||
user = nil
|
user = nil
|
||||||
project = nil
|
project = nil
|
||||||
github_site ||= "github.com"
|
github_site ||= "github.com"
|
||||||
if arg0 && !arg1
|
if arg0 && !arg1
|
||||||
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or "skywinder/Github-Changelog-Generator" to user and name
|
# this match should parse strings such "https://github.com/skywinder/Github-Changelog-Generator" or
|
||||||
puts arg0
|
# "skywinder/Github-Changelog-Generator" to user and name
|
||||||
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(arg0)
|
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(arg0)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@@ -248,35 +273,40 @@ module GitHubChangelogGenerator
|
|||||||
[user, project]
|
[user, project]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Try to find user and project name from git remote output
|
# These patterns match these formats:
|
||||||
#
|
#
|
||||||
# @param [String] output of git remote command
|
# ```
|
||||||
# @return [Array] user and project
|
|
||||||
def self.user_project_from_remote(remote)
|
|
||||||
# try to find repo in format:
|
|
||||||
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
# origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch)
|
||||||
# git@github.com:skywinder/Github-Changelog-Generator.git
|
# git@github.com:skywinder/Github-Changelog-Generator.git
|
||||||
regex1 = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/
|
# ```
|
||||||
|
#
|
||||||
# try to find repo in format:
|
# and
|
||||||
|
#
|
||||||
|
# ```
|
||||||
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
# origin https://github.com/skywinder/ChangelogMerger (fetch)
|
||||||
# https://github.com/skywinder/ChangelogMerger
|
# https://github.com/skywinder/ChangelogMerger
|
||||||
regex2 = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/
|
# ```
|
||||||
|
GIT_REMOTE_PATTERNS = [
|
||||||
remote_structures = [regex1, regex2]
|
/.*(?:[:\/])(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*)(?:\.git).*/,
|
||||||
|
/.*\/(?<user>(?:-|\w|\.)*)\/(?<project>(?:-|\w|\.)*).*/
|
||||||
|
]
|
||||||
|
|
||||||
|
# Returns GitHub username and project from git remote output
|
||||||
|
#
|
||||||
|
# @param git_remote_output [String] Output of git remote command
|
||||||
|
#
|
||||||
|
# @return [Array] user and project
|
||||||
|
def self.user_project_from_remote(git_remote_output)
|
||||||
user = nil
|
user = nil
|
||||||
project = nil
|
project = nil
|
||||||
remote_structures.each do |regex|
|
GIT_REMOTE_PATTERNS.each do |git_remote_pattern|
|
||||||
matches = Regexp.new(regex).match(remote)
|
git_remote_pattern =~ git_remote_output
|
||||||
|
|
||||||
if matches && matches[1] && matches[2]
|
if Regexp.last_match
|
||||||
puts "Detected user:#{matches[1]}, project:#{matches[2]}"
|
user = Regexp.last_match(:user)
|
||||||
user = matches[1]
|
project = Regexp.last_match(:project)
|
||||||
project = matches[2]
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
break unless matches.nil?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
[user, project]
|
[user, project]
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module GitHubChangelogGenerator
|
|||||||
unreleased_only unreleased unreleased_label
|
unreleased_only unreleased unreleased_label
|
||||||
compare_link include_labels exclude_labels
|
compare_link include_labels exclude_labels
|
||||||
bug_labels enhancement_labels
|
bug_labels enhancement_labels
|
||||||
between_tags exclude_tags since_tag max_issues
|
between_tags exclude_tags exclude_tags_regex since_tag max_issues
|
||||||
github_site github_endpoint simple_list
|
github_site github_endpoint simple_list
|
||||||
future_release release_branch verbose release_url
|
future_release release_branch verbose release_url
|
||||||
base )
|
base )
|
||||||
@@ -46,7 +46,7 @@ module GitHubChangelogGenerator
|
|||||||
# mimick parse_options
|
# mimick parse_options
|
||||||
options = Parser.default_options
|
options = Parser.default_options
|
||||||
|
|
||||||
Parser.user_and_project_from_git(options)
|
Parser.fetch_user_and_project(options)
|
||||||
|
|
||||||
OPTIONS.each do |o|
|
OPTIONS.each do |o|
|
||||||
v = instance_variable_get("@#{o}")
|
v = instance_variable_get("@#{o}")
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
VERSION = "1.12.1"
|
VERSION = "1.13.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ describe GitHubChangelogGenerator::ParserFile do
|
|||||||
header: "=== Changelog ==="))
|
header: "=== Changelog ==="))
|
||||||
end
|
end
|
||||||
|
|
||||||
context "turns exclude-labels into an Array", bug: '#327' do
|
context "turns exclude-labels into an Array", bug: "#327" do
|
||||||
let(:file) do
|
let(:file) do
|
||||||
StringIO.new(<<EOF
|
StringIO.new(<<EOF
|
||||||
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
|
exclude-labels=73a91042-da6f-11e5-9335-1040f38d7f90,7adf83b4-da6f-11e5-ae18-1040f38d7f90
|
||||||
|
|||||||
@@ -56,5 +56,25 @@ describe GitHubChangelogGenerator::Parser do
|
|||||||
it { is_expected.to be_a(Array) }
|
it { is_expected.to be_a(Array) }
|
||||||
it { is_expected.to match_array([nil, nil]) }
|
it { is_expected.to match_array([nil, nil]) }
|
||||||
end
|
end
|
||||||
|
context "when all args is not nil" do
|
||||||
|
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", "blah", "https://codeclimate.com") }
|
||||||
|
it { is_expected.to be_a(Array) }
|
||||||
|
it { is_expected.to match_array([nil, nil]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
describe ".fetch_user_and_project" do
|
||||||
|
before :each do
|
||||||
|
ARGV = ["https://github.com/skywinder/github-changelog-generator"]
|
||||||
|
end
|
||||||
|
context do
|
||||||
|
let(:valid_user) { "initialized_user" }
|
||||||
|
let(:options) { { user: valid_user } }
|
||||||
|
let(:options_before_change) { options.dup }
|
||||||
|
it "should leave user unchanged" do
|
||||||
|
expect { GitHubChangelogGenerator::Parser.fetch_user_and_project(options) }.to change { options }
|
||||||
|
.from(options_before_change)
|
||||||
|
.to(options_before_change.merge(project: "github-changelog-generator"))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user