Compare commits
57 Commits
dlanileona
...
1.10.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7aed6aa528 | ||
|
|
9ddc676a44 | ||
|
|
1b9a251c6b | ||
|
|
88ec105c7d | ||
|
|
3a784b16d6 | ||
|
|
0cc7065efc | ||
|
|
53df784ec3 | ||
|
|
d81cb5fcb7 | ||
|
|
8c8c7c4d3c | ||
|
|
34b8fc7217 | ||
|
|
6d02c509cd | ||
|
|
ac1c70978d | ||
|
|
670ced30e3 | ||
|
|
b0b4b1cf0a | ||
|
|
af97beeb60 | ||
|
|
384b080ad0 | ||
|
|
0e4c775ce4 | ||
|
|
c6eac743b6 | ||
|
|
033c7e8d79 | ||
|
|
bffe7cd9ff | ||
|
|
9832dce93c | ||
|
|
d2fa9d3565 | ||
|
|
8f7af37d1e | ||
|
|
12bc3550e1 | ||
|
|
5d5a48e00e | ||
|
|
35b581240f | ||
|
|
01a0c05a02 | ||
|
|
90ea75c471 | ||
|
|
46aaa5f205 | ||
|
|
95d32abbcb | ||
|
|
47c0332b55 | ||
|
|
c63b2e1fb9 | ||
|
|
29fd202ed0 | ||
|
|
fc1fb2eb9a | ||
|
|
afbb47ecf3 | ||
|
|
1d1965e7fb | ||
|
|
06a8fe8169 | ||
|
|
138abfe676 | ||
|
|
3fdf0c64df | ||
|
|
645f96ace6 | ||
|
|
dfdeb0e633 | ||
|
|
8d44b16e73 | ||
|
|
a6e6363cdd | ||
|
|
dd0d82ab91 | ||
|
|
8a87be8f4e | ||
|
|
8f78bb0cc6 | ||
|
|
b1d2b7d828 | ||
|
|
3fb75c825f | ||
|
|
d227464c33 | ||
|
|
5a9928c18a | ||
|
|
2dda090e6b | ||
|
|
38ddf055ae | ||
|
|
92ade3a625 | ||
|
|
3d1789a2d1 | ||
|
|
4f64cdb7d5 | ||
|
|
9dea79fe40 | ||
|
|
d959639e2a |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -0,0 +1 @@
|
|||||||
|
coverage/
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
sudo: false
|
||||||
language: ruby
|
language: ruby
|
||||||
before_install: gem update --system
|
before_install:
|
||||||
|
- gem update --system
|
||||||
|
- gem install bundler
|
||||||
rvm:
|
rvm:
|
||||||
- 2.1.0
|
- 2.1.0
|
||||||
script:
|
script:
|
||||||
|
|||||||
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,5 +1,28 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## [1.10.0](https://github.com/skywinder/github-changelog-generator/tree/1.10.0) (2016-01-05)
|
||||||
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.9.0...1.10.0)
|
||||||
|
|
||||||
|
**Implemented enhancements:**
|
||||||
|
|
||||||
|
- Rubocop: less complex methods in parser.rb [\#297](https://github.com/skywinder/github-changelog-generator/pull/297) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Introduce ParserError exception class [\#296](https://github.com/skywinder/github-changelog-generator/pull/296) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- ParserFile: support values with equals signs [\#285](https://github.com/skywinder/github-changelog-generator/pull/285) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
|
||||||
|
**Closed issues:**
|
||||||
|
|
||||||
|
- PRs not closed on master branch show up in changelog [\#280](https://github.com/skywinder/github-changelog-generator/issues/280)
|
||||||
|
|
||||||
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Update bundler [\#306](https://github.com/skywinder/github-changelog-generator/pull/306) ([SteveGilvarry](https://github.com/SteveGilvarry))
|
||||||
|
- Fixes \#280 Add release-branch option to filter the Pull Requests [\#305](https://github.com/skywinder/github-changelog-generator/pull/305) ([SteveGilvarry](https://github.com/SteveGilvarry))
|
||||||
|
- Add options to def self.user\_and\_project\_from\_git to fix parser.rb:19… [\#303](https://github.com/skywinder/github-changelog-generator/pull/303) ([SteveGilvarry](https://github.com/SteveGilvarry))
|
||||||
|
- Git ignore coverage/ [\#300](https://github.com/skywinder/github-changelog-generator/pull/300) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- \[refactor\] Fix docblock datatype, use \#map [\#299](https://github.com/skywinder/github-changelog-generator/pull/299) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- \[refactor\] Reader: positive Boolean; unused \#map [\#298](https://github.com/skywinder/github-changelog-generator/pull/298) ([olleolleolle](https://github.com/olleolleolle))
|
||||||
|
- Add base option to RakeTask [\#287](https://github.com/skywinder/github-changelog-generator/pull/287) ([jkeiser](https://github.com/jkeiser))
|
||||||
|
|
||||||
## [1.9.0](https://github.com/skywinder/github-changelog-generator/tree/1.9.0) (2015-09-17)
|
## [1.9.0](https://github.com/skywinder/github-changelog-generator/tree/1.9.0) (2015-09-17)
|
||||||
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.8.5...1.9.0)
|
[Full Changelog](https://github.com/skywinder/github-changelog-generator/compare/1.8.5...1.9.0)
|
||||||
|
|
||||||
|
|||||||
68
Gemfile.lock
68
Gemfile.lock
@@ -1,62 +1,59 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: .
|
remote: .
|
||||||
specs:
|
specs:
|
||||||
github_changelog_generator (1.9.0)
|
github_changelog_generator (1.10.0)
|
||||||
colorize (~> 0.7)
|
colorize (~> 0.7)
|
||||||
github_api (~> 0.12)
|
github_api (~> 0.12)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.3.8)
|
addressable (2.4.0)
|
||||||
ast (2.0.0)
|
ast (2.2.0)
|
||||||
astrolabe (1.3.1)
|
astrolabe (1.3.1)
|
||||||
parser (~> 2.2)
|
parser (~> 2.2)
|
||||||
codeclimate-test-reporter (0.4.7)
|
codeclimate-test-reporter (0.4.8)
|
||||||
simplecov (>= 0.7.1, < 1.0.0)
|
simplecov (>= 0.7.1, < 1.0.0)
|
||||||
colorize (0.7.7)
|
colorize (0.7.7)
|
||||||
coveralls (0.8.2)
|
coveralls (0.8.10)
|
||||||
json (~> 1.8)
|
json (~> 1.8)
|
||||||
rest-client (>= 1.6.8, < 2)
|
rest-client (>= 1.6.8, < 2)
|
||||||
simplecov (~> 0.10.0)
|
simplecov (~> 0.11.0)
|
||||||
term-ansicolor (~> 1.3)
|
term-ansicolor (~> 1.3)
|
||||||
thor (~> 0.19.1)
|
thor (~> 0.19.1)
|
||||||
|
tins (~> 1.6.0)
|
||||||
descendants_tracker (0.0.4)
|
descendants_tracker (0.0.4)
|
||||||
thread_safe (~> 0.3, >= 0.3.1)
|
thread_safe (~> 0.3, >= 0.3.1)
|
||||||
diff-lcs (1.2.5)
|
diff-lcs (1.2.5)
|
||||||
docile (1.1.5)
|
docile (1.1.5)
|
||||||
domain_name (0.5.24)
|
domain_name (0.5.25)
|
||||||
unf (>= 0.0.5, < 1.0.0)
|
unf (>= 0.0.5, < 1.0.0)
|
||||||
faraday (0.9.1)
|
faraday (0.9.2)
|
||||||
multipart-post (>= 1.2, < 3)
|
multipart-post (>= 1.2, < 3)
|
||||||
github_api (0.12.4)
|
github_api (0.13.1)
|
||||||
addressable (~> 2.3)
|
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)
|
multi_json (>= 1.7.5, < 2.0)
|
||||||
nokogiri (~> 1.6.6)
|
|
||||||
oauth2
|
oauth2
|
||||||
hashie (3.4.2)
|
hashie (3.4.3)
|
||||||
http-cookie (1.0.2)
|
http-cookie (1.0.2)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
jwt (1.5.1)
|
jwt (1.5.2)
|
||||||
mime-types (2.6.1)
|
mime-types (2.99)
|
||||||
mini_portile (0.6.2)
|
|
||||||
multi_json (1.11.2)
|
multi_json (1.11.2)
|
||||||
multi_xml (0.5.5)
|
multi_xml (0.5.5)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
netrc (0.10.3)
|
netrc (0.11.0)
|
||||||
nokogiri (1.6.6.2)
|
|
||||||
mini_portile (~> 0.6.0)
|
|
||||||
oauth2 (1.0.0)
|
oauth2 (1.0.0)
|
||||||
faraday (>= 0.8, < 0.10)
|
faraday (>= 0.8, < 0.10)
|
||||||
jwt (~> 1.0)
|
jwt (~> 1.0)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
multi_xml (~> 0.5)
|
multi_xml (~> 0.5)
|
||||||
rack (~> 1.2)
|
rack (~> 1.2)
|
||||||
parser (2.2.2.6)
|
parser (2.2.3.0)
|
||||||
ast (>= 1.1, < 3.0)
|
ast (>= 1.1, < 3.0)
|
||||||
powerpack (0.1.1)
|
powerpack (0.1.1)
|
||||||
rack (1.6.4)
|
rack (1.6.4)
|
||||||
@@ -66,27 +63,28 @@ GEM
|
|||||||
http-cookie (>= 1.0.2, < 2.0)
|
http-cookie (>= 1.0.2, < 2.0)
|
||||||
mime-types (>= 1.16, < 3.0)
|
mime-types (>= 1.16, < 3.0)
|
||||||
netrc (~> 0.7)
|
netrc (~> 0.7)
|
||||||
rspec (3.3.0)
|
rspec (3.4.0)
|
||||||
rspec-core (~> 3.3.0)
|
rspec-core (~> 3.4.0)
|
||||||
rspec-expectations (~> 3.3.0)
|
rspec-expectations (~> 3.4.0)
|
||||||
rspec-mocks (~> 3.3.0)
|
rspec-mocks (~> 3.4.0)
|
||||||
rspec-core (3.3.2)
|
rspec-core (3.4.1)
|
||||||
rspec-support (~> 3.3.0)
|
rspec-support (~> 3.4.0)
|
||||||
rspec-expectations (3.3.1)
|
rspec-expectations (3.4.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.3.0)
|
rspec-support (~> 3.4.0)
|
||||||
rspec-mocks (3.3.2)
|
rspec-mocks (3.4.0)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.3.0)
|
rspec-support (~> 3.4.0)
|
||||||
rspec-support (3.3.0)
|
rspec-support (3.4.1)
|
||||||
rubocop (0.32.1)
|
rubocop (0.35.1)
|
||||||
astrolabe (~> 1.3)
|
astrolabe (~> 1.3)
|
||||||
parser (>= 2.2.2.5, < 3.0)
|
parser (>= 2.2.3.0, < 3.0)
|
||||||
powerpack (~> 0.1)
|
powerpack (~> 0.1)
|
||||||
rainbow (>= 1.99.1, < 3.0)
|
rainbow (>= 1.99.1, < 3.0)
|
||||||
ruby-progressbar (~> 1.4)
|
ruby-progressbar (~> 1.7)
|
||||||
|
tins (<= 1.6.0)
|
||||||
ruby-progressbar (1.7.5)
|
ruby-progressbar (1.7.5)
|
||||||
simplecov (0.10.0)
|
simplecov (0.11.1)
|
||||||
docile (~> 1.1.0)
|
docile (~> 1.1.0)
|
||||||
json (~> 1.8)
|
json (~> 1.8)
|
||||||
simplecov-html (~> 0.10.0)
|
simplecov-html (~> 0.10.0)
|
||||||
@@ -95,7 +93,7 @@ GEM
|
|||||||
tins (~> 1.0)
|
tins (~> 1.0)
|
||||||
thor (0.19.1)
|
thor (0.19.1)
|
||||||
thread_safe (0.3.5)
|
thread_safe (0.3.5)
|
||||||
tins (1.5.4)
|
tins (1.6.0)
|
||||||
unf (0.1.4)
|
unf (0.1.4)
|
||||||
unf_ext
|
unf_ext
|
||||||
unf_ext (0.0.7.1)
|
unf_ext (0.0.7.1)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ To make it easier for users and contributors to see precisely what notable chang
|
|||||||
### *Why should I care?*
|
### *Why should I care?*
|
||||||
Because software tools are for people. If you don’t care, why are you contributing to open source? Surely, there must be a kernel (ha!) of care somewhere in that lovely little brain of yours.
|
Because software tools are for people. If you don’t care, why are you contributing to open source? Surely, there must be a kernel (ha!) of care somewhere in that lovely little brain of yours.
|
||||||
|
|
||||||
> :copyright: *[http://keepachangelog.com](http://keepachangelog.com/)*
|
> :arrow_right: *[http://keepachangelog.com](http://keepachangelog.com/)*
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ It's time to create this token or wait for 1 hour before GitHub reset the counte
|
|||||||
## Migrating from a manual changelog
|
## Migrating from a manual changelog
|
||||||
|
|
||||||
Knowing how dedicated you are to your project, you probably haven't been waiting for github-changelog-generator to keep a changelog,
|
Knowing how dedicated you are to your project, you probably haven't been waiting for github-changelog-generator to keep a changelog,
|
||||||
but you most likely wouln't like to have to open issues and PRs for all past features listed in your historic changelog.
|
but you most likely wouldn't like to have to open issues and PRs for all past features listed in your historic changelog.
|
||||||
|
|
||||||
That's where `--base` comes handy. This option lets you pass a static changelog to be appended at the end of the generated entries.
|
That's where `--base` comes handy. This option lets you pass a static changelog to be appended at the end of the generated entries.
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
**Merged pull requests:**
|
**Merged pull requests:**
|
||||||
|
|
||||||
|
- Merged br \(should appear in change log also\) [\#21](https://github.com/skywinder/changelog_test/pull/21) ([skywinder](https://github.com/skywinder))
|
||||||
- This a PR with a lot of comments and events [\#17](https://github.com/skywinder/changelog_test/pull/17) ([skywinder](https://github.com/skywinder))
|
- This a PR with a lot of comments and events [\#17](https://github.com/skywinder/changelog_test/pull/17) ([skywinder](https://github.com/skywinder))
|
||||||
- This PR closes 14 from commit [\#15](https://github.com/skywinder/changelog_test/pull/15) ([skywinder](https://github.com/skywinder))
|
- This PR closes 14 from commit [\#15](https://github.com/skywinder/changelog_test/pull/15) ([skywinder](https://github.com/skywinder))
|
||||||
- This PR to close \#12 from body [\#13](https://github.com/skywinder/changelog_test/pull/13) ([skywinder](https://github.com/skywinder))
|
- This PR to close \#12 from body [\#13](https://github.com/skywinder/changelog_test/pull/13) ([skywinder](https://github.com/skywinder))
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ module GitHubChangelogGenerator
|
|||||||
@user = @options[:user]
|
@user = @options[:user]
|
||||||
@project = @options[:project]
|
@project = @options[:project]
|
||||||
@github_token = fetch_github_token
|
@github_token = fetch_github_token
|
||||||
github_options = { per_page: PER_PAGE_NUMBER }
|
@github_options = { per_page: PER_PAGE_NUMBER }
|
||||||
github_options[:oauth_token] = @github_token unless @github_token.nil?
|
@github_options[:oauth_token] = @github_token unless @github_token.nil?
|
||||||
github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
|
@github_options[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
|
||||||
github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil?
|
@github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil?
|
||||||
|
|
||||||
@github = check_github_response { Github.new github_options }
|
@github = check_github_response { Github.new @github_options }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns GitHub token. First try to use variable, provided by --token option,
|
# Returns GitHub token. First try to use variable, provided by --token option,
|
||||||
@@ -123,7 +123,16 @@ Make sure, that you push tags to remote repo via 'git push --tags'".yellow
|
|||||||
def fetch_closed_pull_requests
|
def fetch_closed_pull_requests
|
||||||
pull_requests = []
|
pull_requests = []
|
||||||
begin
|
begin
|
||||||
response = @github.pull_requests.list @options[:user], @options[:project], state: "closed"
|
if @options[:release_branch].nil?
|
||||||
|
response = @github.pull_requests.list @options[:user],
|
||||||
|
@options[:project],
|
||||||
|
state: "closed"
|
||||||
|
else
|
||||||
|
response = @github.pull_requests.list @options[:user],
|
||||||
|
@options[:project],
|
||||||
|
state: "closed",
|
||||||
|
base: @options[:release_branch]
|
||||||
|
end
|
||||||
page_i = 0
|
page_i = 0
|
||||||
count_pages = response.count_pages
|
count_pages = response.count_pages
|
||||||
response.each_page do |page|
|
response.each_page do |page|
|
||||||
|
|||||||
@@ -178,9 +178,11 @@ module GitHubChangelogGenerator
|
|||||||
fetched_pr = closed_pull_requests.find do |fpr|
|
fetched_pr = closed_pull_requests.find do |fpr|
|
||||||
fpr.number == pr.number
|
fpr.number == pr.number
|
||||||
end
|
end
|
||||||
|
if fetched_pr
|
||||||
pr[:merged_at] = fetched_pr[:merged_at]
|
pr[:merged_at] = fetched_pr[:merged_at]
|
||||||
closed_pull_requests.delete(fetched_pr)
|
closed_pull_requests.delete(fetched_pr)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
pull_requests.select! do |pr|
|
pull_requests.select! do |pr|
|
||||||
!pr[:merged_at].nil?
|
!pr[:merged_at].nil?
|
||||||
|
|||||||
@@ -7,22 +7,16 @@ module GitHubChangelogGenerator
|
|||||||
class Parser
|
class Parser
|
||||||
# parse options with optparse
|
# parse options with optparse
|
||||||
def self.parse_options
|
def self.parse_options
|
||||||
options = get_default_options
|
options = default_options
|
||||||
|
|
||||||
parser_file = ParserFile.new options
|
ParserFile.new(options).parse!
|
||||||
parser_file.parse!
|
|
||||||
|
|
||||||
parser = setup_parser(options)
|
parser = setup_parser(options)
|
||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
if options[:user].nil? || options[:project].nil?
|
user_and_project_from_git(options)
|
||||||
detect_user_and_project(options, ARGV[0], ARGV[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
if !options[:user] || !options[:project]
|
abort(parser.banner) unless options[:user] && options[:project]
|
||||||
puts parser.banner
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
|
|
||||||
print_options(options)
|
print_options(options)
|
||||||
|
|
||||||
@@ -149,6 +143,9 @@ module GitHubChangelogGenerator
|
|||||||
opts.on("--future-release [RELEASE-VERSION]", "Put the unreleased changes in the specified release number.") do |future_release|
|
opts.on("--future-release [RELEASE-VERSION]", "Put the unreleased changes in the specified release number.") do |future_release|
|
||||||
options[:future_release] = future_release
|
options[:future_release] = future_release
|
||||||
end
|
end
|
||||||
|
opts.on("--release-branch [RELEASE-BRANCH]", "Limit pull requests to the release branch, such as master or release") do |release_branch|
|
||||||
|
options[:release_branch] = release_branch
|
||||||
|
end
|
||||||
opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v|
|
opts.on("--[no-]verbose", "Run verbosely. Default is true") do |v|
|
||||||
options[:verbose] = v
|
options[:verbose] = v
|
||||||
end
|
end
|
||||||
@@ -165,8 +162,8 @@ module GitHubChangelogGenerator
|
|||||||
end
|
end
|
||||||
|
|
||||||
# just get default options
|
# just get default options
|
||||||
def self.get_default_options
|
def self.default_options
|
||||||
options = {
|
{
|
||||||
tag1: nil,
|
tag1: nil,
|
||||||
tag2: nil,
|
tag2: nil,
|
||||||
date_format: "%Y-%m-%d",
|
date_format: "%Y-%m-%d",
|
||||||
@@ -194,14 +191,19 @@ module GitHubChangelogGenerator
|
|||||||
enhancement_prefix: "**Implemented enhancements:**",
|
enhancement_prefix: "**Implemented enhancements:**",
|
||||||
git_remote: "origin"
|
git_remote: "origin"
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
options
|
def self.user_and_project_from_git(options)
|
||||||
|
if options[:user].nil? || options[:project].nil?
|
||||||
|
detect_user_and_project(options, ARGV[0], ARGV[1])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Detects user and project from git
|
# Detects user and project from git
|
||||||
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
|
def self.detect_user_and_project(options, arg0 = nil, arg1 = nil)
|
||||||
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
|
options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site])
|
||||||
if !options[:user] || !options[:project]
|
return if options[:user] && options[:project]
|
||||||
|
|
||||||
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
if ENV["RUBYLIB"] =~ /ruby-debug-ide/
|
||||||
options[:user] = "skywinder"
|
options[:user] = "skywinder"
|
||||||
options[:project] = "changelog_test"
|
options[:project] = "changelog_test"
|
||||||
@@ -210,13 +212,12 @@ module GitHubChangelogGenerator
|
|||||||
options[:user], options[:project] = user_project_from_remote(remote)
|
options[:user], options[:project] = user_project_from_remote(remote)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# Try to find user and project name from git remote output
|
# Try to find user and project name from git remote output
|
||||||
#
|
#
|
||||||
# @param [String] output of git remote command
|
# @param [String] output of git remote command
|
||||||
# @return [Array] user and project
|
# @return [Array] user and project
|
||||||
def self.user_project_from_option(arg0, arg1, github_site = nil)
|
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"
|
||||||
@@ -229,10 +230,10 @@ module GitHubChangelogGenerator
|
|||||||
param = match[2].nil?
|
param = match[2].nil?
|
||||||
rescue
|
rescue
|
||||||
puts "Can't detect user and name from first parameter: '#{arg0}' -> exit'"
|
puts "Can't detect user and name from first parameter: '#{arg0}' -> exit'"
|
||||||
exit
|
return
|
||||||
end
|
end
|
||||||
if param
|
if param
|
||||||
exit
|
return
|
||||||
else
|
else
|
||||||
user = match[1]
|
user = match[1]
|
||||||
project = match[2]
|
project = match[2]
|
||||||
@@ -275,9 +276,4 @@ module GitHubChangelogGenerator
|
|||||||
[user, project]
|
[user, project]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
|
||||||
remote = "invalid reference to project"
|
|
||||||
p user_project_from_option(ARGV[0], ARGV[1], remote)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
|
ParserError = Class.new(StandardError)
|
||||||
|
|
||||||
class ParserFile
|
class ParserFile
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
@options = options
|
@options = options
|
||||||
@@ -22,7 +24,7 @@ module GitHubChangelogGenerator
|
|||||||
value = false if value =~ (/^(false|f|no|n|0)$/i)
|
value = false if value =~ (/^(false|f|no|n|0)$/i)
|
||||||
@options[key_sym] = value
|
@options[key_sym] = value
|
||||||
rescue
|
rescue
|
||||||
raise "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
|
raise ParserError, "Config file #{file} is incorrect in line \"#{line.gsub(/[\n\r]+/, '')}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a the setting as a symbol and its string value sans newlines.
|
# Returns a the setting as a symbol and its string value sans newlines.
|
||||||
|
|||||||
@@ -53,31 +53,28 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
@heading_structures.each do |regexp|
|
@heading_structures.each do |regexp|
|
||||||
matches = Regexp.new(regexp).match(heading)
|
matches = Regexp.new(regexp).match(heading)
|
||||||
captures.merge!(Hash[matches.names.map.zip(matches.captures)]) unless matches.nil?
|
if matches
|
||||||
|
captures.merge!(Hash[matches.names.zip(matches.captures)])
|
||||||
# Try Regular Expressions until you find one that delivers results
|
break
|
||||||
break unless matches.nil?
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
captures
|
captures
|
||||||
end
|
end
|
||||||
|
|
||||||
# Parse the given ChangeLog data into a Hash
|
# Parse the given ChangeLog data into a list of Hashes
|
||||||
#
|
#
|
||||||
# @param [String] data File data from the ChangeLog.md
|
# @param [String] data File data from the ChangeLog.md
|
||||||
# @return [Hash] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...]
|
# @return [Array<Hash>] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...]
|
||||||
def parse(data)
|
def parse(data)
|
||||||
sections = data.split(/^## .+?$/)
|
sections = data.split(/^## .+?$/)
|
||||||
headings = data.scan(/^## .+?$/)
|
headings = data.scan(/^## .+?$/)
|
||||||
changelog = []
|
|
||||||
|
|
||||||
headings.each_with_index do |heading, index|
|
headings.each_with_index.map do |heading, index|
|
||||||
captures = parse_heading(heading)
|
section = parse_heading(heading)
|
||||||
captures["content"] = sections.at(index + 1)
|
section["content"] = sections.at(index + 1)
|
||||||
changelog.push captures
|
section
|
||||||
end
|
end
|
||||||
|
|
||||||
changelog
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(file_path)
|
def read(file_path)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ module GitHubChangelogGenerator
|
|||||||
bug_labels enhancement_labels
|
bug_labels enhancement_labels
|
||||||
between_tags exclude_tags since_tag max_issues
|
between_tags exclude_tags since_tag max_issues
|
||||||
github_site github_endpoint simple_list
|
github_site github_endpoint simple_list
|
||||||
future_release verbose release_url base )
|
future_release release_branch verbose release_url
|
||||||
|
base )
|
||||||
|
|
||||||
OPTIONS.each do |o|
|
OPTIONS.each do |o|
|
||||||
attr_accessor o.to_sym
|
attr_accessor o.to_sym
|
||||||
@@ -43,11 +44,9 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
task @name do
|
task @name do
|
||||||
# mimick parse_options
|
# mimick parse_options
|
||||||
options = Parser.get_default_options
|
options = Parser.default_options
|
||||||
|
|
||||||
if options[:user].nil? || options[:project].nil?
|
Parser.user_and_project_from_git(options)
|
||||||
Parser.detect_user_and_project(options)
|
|
||||||
end
|
|
||||||
|
|
||||||
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.9.0"
|
VERSION = "1.10.1"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ describe GitHubChangelogGenerator::ParserFile do
|
|||||||
let(:options) { { params_file: "spec/files/github_changelog_params_incorrect" } }
|
let(:options) { { params_file: "spec/files/github_changelog_params_incorrect" } }
|
||||||
let(:options_before_change) { options.dup }
|
let(:options_before_change) { options.dup }
|
||||||
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
|
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
|
||||||
it { expect { parse.parse! }.to raise_error }
|
it { expect { parse.parse! }.to raise_error(GitHubChangelogGenerator::ParserError) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when override default values" do
|
context "when override default values" do
|
||||||
let(:default_options) { GitHubChangelogGenerator::Parser.get_default_options }
|
let(:default_options) { GitHubChangelogGenerator::Parser.default_options }
|
||||||
let(:options) { { params_file: "spec/files/github_changelog_params_override" }.merge(default_options) }
|
let(:options) { { params_file: "spec/files/github_changelog_params_override" }.merge(default_options) }
|
||||||
let(:options_before_change) { options.dup }
|
let(:options_before_change) { options.dup }
|
||||||
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
|
let(:parse) { GitHubChangelogGenerator::ParserFile.new(options) }
|
||||||
|
|||||||
@@ -28,16 +28,16 @@ describe GitHubChangelogGenerator::Parser do
|
|||||||
end
|
end
|
||||||
describe ".user_project_from_option" do
|
describe ".user_project_from_option" do
|
||||||
context "when option is invalid" do
|
context "when option is invalid" do
|
||||||
it("should exit") { expect { GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil) }.to raise_error(SystemExit) }
|
it("should return nil") { expect(GitHubChangelogGenerator::Parser.user_project_from_option("blah", nil, nil)).to be_nil }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when option is valid" do
|
context "when option is valid" do
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil) }
|
subject { GitHubChangelogGenerator::Parser.user_project_from_option("skywinder/ActionSheetPicker-3.0", nil, nil) }
|
||||||
it { is_expected.to be_a(Array) }
|
it { is_expected.to be_a(Array) }
|
||||||
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
it { is_expected.to match_array(["skywinder", "ActionSheetPicker-3.0"]) }
|
||||||
end
|
end
|
||||||
context "when option nil" do
|
context "when option nil" do
|
||||||
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil) }
|
subject { GitHubChangelogGenerator::Parser.user_project_from_option(nil, nil, nil) }
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user