Compare commits
3 Commits
master
...
feature/fi
Author | SHA1 | Date | |
---|---|---|---|
|
d4664e389d | ||
|
0e352886ea | ||
|
01e30d1132 |
|
@ -1,37 +1,37 @@
|
|||
# This configuration was generated by `rubocop --auto-gen-config`
|
||||
# on 2015-05-25 12:59:32 +0300 using RuboCop version 0.31.0.
|
||||
# on 2015-05-25 17:16:04 +0300 using RuboCop version 0.31.0.
|
||||
# The point is for the user to remove these configuration records
|
||||
# one by one as the offenses are removed from the code base.
|
||||
# Note that changes in the inspected code, or installation of new
|
||||
# versions of RuboCop, may require this file to be generated again.
|
||||
|
||||
# Offense count: 16
|
||||
# Offense count: 14
|
||||
Metrics/AbcSize:
|
||||
Max: 68
|
||||
Max: 57
|
||||
|
||||
# Offense count: 4
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
Max: 182
|
||||
|
||||
# Offense count: 3
|
||||
# Offense count: 1
|
||||
Metrics/CyclomaticComplexity:
|
||||
Max: 9
|
||||
Max: 7
|
||||
|
||||
# Offense count: 22
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/MethodLength:
|
||||
Max: 117
|
||||
Max: 84
|
||||
|
||||
# Offense count: 4
|
||||
# Offense count: 1
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 12
|
||||
Max: 8
|
||||
|
||||
# Offense count: 2
|
||||
Style/AccessorMethodName:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 6
|
||||
# Offense count: 8
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
|
|
176
lib/CHANGELOG.md
176
lib/CHANGELOG.md
|
@ -1,182 +1,34 @@
|
|||
# Change Log
|
||||
|
||||
## [Unreleased](https://github.com/sindresorhus/awesome/tree/HEAD)
|
||||
## [0.0.4](https://github.com/skywinder/changelog_test/tree/0.0.4) (2015-05-22)
|
||||
|
||||
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.3...0.0.4)
|
||||
|
||||
**Closed issues:**
|
||||
|
||||
- Suggestion [\#151](https://github.com/sindresorhus/awesome/issues/151)
|
||||
|
||||
- ta bugando [\#149](https://github.com/sindresorhus/awesome/issues/149)
|
||||
|
||||
- Add Regex [\#147](https://github.com/sindresorhus/awesome/issues/147)
|
||||
|
||||
- Add "Mad Science Modules" [\#138](https://github.com/sindresorhus/awesome/issues/138)
|
||||
|
||||
- you dont know js [\#130](https://github.com/sindresorhus/awesome/issues/130)
|
||||
|
||||
- O'Reilly Media Inc [\#129](https://github.com/sindresorhus/awesome/issues/129)
|
||||
|
||||
- List of useful Git Hook and .gitignore files [\#128](https://github.com/sindresorhus/awesome/issues/128)
|
||||
|
||||
- Please add the list of "Open Source Clones of Popular Games" [\#118](https://github.com/sindresorhus/awesome/issues/118)
|
||||
|
||||
- Underscore character in front of the "Basics" section under Haskell [\#114](https://github.com/sindresorhus/awesome/issues/114)
|
||||
|
||||
- Arrange the lists in alphabetical Order. [\#112](https://github.com/sindresorhus/awesome/issues/112)
|
||||
|
||||
- AwesomeOpenSource [\#107](https://github.com/sindresorhus/awesome/issues/107)
|
||||
|
||||
- Suggestion. [\#73](https://github.com/sindresorhus/awesome/issues/73)
|
||||
|
||||
- Suggestion [\#51](https://github.com/sindresorhus/awesome/issues/51)
|
||||
|
||||
- Awesome Radio [\#33](https://github.com/sindresorhus/awesome/issues/33)
|
||||
|
||||
- Have you considered breaking + regrouping Miscellaneous section? [\#20](https://github.com/sindresorhus/awesome/issues/20)
|
||||
|
||||
- Node.js a programming language? [\#5](https://github.com/sindresorhus/awesome/issues/5)
|
||||
- Test issue, that should appear in 0.0.4 [\#3](https://github.com/skywinder/changelog_test/issues/3)
|
||||
|
||||
**Merged pull requests:**
|
||||
|
||||
- Add awesome-slack [\#156](https://github.com/sindresorhus/awesome/pull/156) ([filipelinhares](https://github.com/filipelinhares))
|
||||
- Add automatically generated change log file. [\#5](https://github.com/skywinder/changelog_test/pull/5) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- Add Elm [\#146](https://github.com/sindresorhus/awesome/pull/146) ([isRuslan](https://github.com/isRuslan))
|
||||
## [v0.0.3](https://github.com/skywinder/changelog_test/tree/v0.0.3) (2015-03-04)
|
||||
|
||||
- Add Awesome Sketch list [\#141](https://github.com/sindresorhus/awesome/pull/141) ([diessica](https://github.com/diessica))
|
||||
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...v0.0.3)
|
||||
|
||||
- Add "Maintenance Modules" [\#139](https://github.com/sindresorhus/awesome/pull/139) ([feross](https://github.com/feross))
|
||||
**Merged pull requests:**
|
||||
|
||||
- Added awesome-delphi [\#137](https://github.com/sindresorhus/awesome/pull/137) ([Teloah](https://github.com/Teloah))
|
||||
- fix \#3. hotfix. Should appear in v0.0.3 [\#4](https://github.com/skywinder/changelog_test/pull/4) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- adds BEM resources page [\#136](https://github.com/sindresorhus/awesome/pull/136) ([sturobson](https://github.com/sturobson))
|
||||
## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04)
|
||||
|
||||
- Added Rails to "Back-end development" [\#135](https://github.com/sindresorhus/awesome/pull/135) ([jpsilvashy](https://github.com/jpsilvashy))
|
||||
[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2)
|
||||
|
||||
- added meteor-awesome [\#132](https://github.com/sindresorhus/awesome/pull/132) ([kefirchik](https://github.com/kefirchik))
|
||||
**Merged pull requests:**
|
||||
|
||||
- Scalable CSS [\#131](https://github.com/sindresorhus/awesome/pull/131) ([h-nazzal](https://github.com/h-nazzal))
|
||||
- Here is a test hotfix should appear in v.0.0.2 [\#2](https://github.com/skywinder/changelog_test/pull/2) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- Changed link to Awesome Laravel [\#127](https://github.com/sindresorhus/awesome/pull/127) ([chiraggude](https://github.com/chiraggude))
|
||||
|
||||
- Add Pyramid framework [\#124](https://github.com/sindresorhus/awesome/pull/124) ([uralbash](https://github.com/uralbash))
|
||||
|
||||
- Added Malware Analysis [\#123](https://github.com/sindresorhus/awesome/pull/123) ([leoruhland](https://github.com/leoruhland))
|
||||
|
||||
- Added Awesome-REST [\#122](https://github.com/sindresorhus/awesome/pull/122) ([leoruhland](https://github.com/leoruhland))
|
||||
|
||||
- Added Awesome Material [\#121](https://github.com/sindresorhus/awesome/pull/121) ([sachin1092](https://github.com/sachin1092))
|
||||
|
||||
- Adding Flask [\#120](https://github.com/sindresorhus/awesome/pull/120) ([yashmehrotra](https://github.com/yashmehrotra))
|
||||
|
||||
- Add GoBooks [\#119](https://github.com/sindresorhus/awesome/pull/119) ([dariubs](https://github.com/dariubs))
|
||||
|
||||
- Added android-ui and ios-ui [\#117](https://github.com/sindresorhus/awesome/pull/117) ([leoruhland](https://github.com/leoruhland))
|
||||
|
||||
- Added the discount for student dev list. [\#113](https://github.com/sindresorhus/awesome/pull/113) ([najela](https://github.com/najela))
|
||||
|
||||
- Add awesome-ctf [\#111](https://github.com/sindresorhus/awesome/pull/111) ([apsdehal](https://github.com/apsdehal))
|
||||
|
||||
- Added awesome-fantasy [\#110](https://github.com/sindresorhus/awesome/pull/110) ([RichardLitt](https://github.com/RichardLitt))
|
||||
|
||||
- Adds awesome-security [\#105](https://github.com/sindresorhus/awesome/pull/105) ([TjWallas](https://github.com/TjWallas))
|
||||
|
||||
- Add awesome-json. [\#102](https://github.com/sindresorhus/awesome/pull/102) ([burningtree](https://github.com/burningtree))
|
||||
|
||||
- Added endangered languages [\#101](https://github.com/sindresorhus/awesome/pull/101) ([RichardLitt](https://github.com/RichardLitt))
|
||||
|
||||
- Add awesome-slack [\#99](https://github.com/sindresorhus/awesome/pull/99) ([matiassingers](https://github.com/matiassingers))
|
||||
|
||||
- add seo repository [\#93](https://github.com/sindresorhus/awesome/pull/93) ([marcobiedermann](https://github.com/marcobiedermann))
|
||||
|
||||
- add 'design and development guides' [\#89](https://github.com/sindresorhus/awesome/pull/89) ([NARKOZ](https://github.com/NARKOZ))
|
||||
|
||||
- Update awesome-cakephp link [\#88](https://github.com/sindresorhus/awesome/pull/88) ([jadb](https://github.com/jadb))
|
||||
|
||||
- Add awesome-ember [\#85](https://github.com/sindresorhus/awesome/pull/85) ([arthurvr](https://github.com/arthurvr))
|
||||
|
||||
- Added awesome boilerplates and projects . [\#84](https://github.com/sindresorhus/awesome/pull/84) ([melvin0008](https://github.com/melvin0008))
|
||||
|
||||
- Move misc frameworks to new back-end dev section [\#83](https://github.com/sindresorhus/awesome/pull/83) ([karlhorky](https://github.com/karlhorky))
|
||||
|
||||
- Add Learn to Program to Misc [\#82](https://github.com/sindresorhus/awesome/pull/82) ([karlhorky](https://github.com/karlhorky))
|
||||
|
||||
- Add browser extensions for GitHub [\#79](https://github.com/sindresorhus/awesome/pull/79) ([stefanbuck](https://github.com/stefanbuck))
|
||||
|
||||
- add computer vision awesome list [\#78](https://github.com/sindresorhus/awesome/pull/78) ([yhsa678](https://github.com/yhsa678))
|
||||
|
||||
- Added Fonts [\#72](https://github.com/sindresorhus/awesome/pull/72) ([brabadu](https://github.com/brabadu))
|
||||
|
||||
- Add awesome-gametalks [\#69](https://github.com/sindresorhus/awesome/pull/69) ([hzoo](https://github.com/hzoo))
|
||||
|
||||
- Add "Cryptography" [\#66](https://github.com/sindresorhus/awesome/pull/66) ([maciejczyzewski](https://github.com/maciejczyzewski))
|
||||
|
||||
- docs\(readme\): include awesome-courses [\#65](https://github.com/sindresorhus/awesome/pull/65) ([gdi2290](https://github.com/gdi2290))
|
||||
|
||||
- Adding awesome-c to the list [\#59](https://github.com/sindresorhus/awesome/pull/59) ([kozross](https://github.com/kozross))
|
||||
|
||||
- Rename 'web development' to 'front end development' [\#58](https://github.com/sindresorhus/awesome/pull/58) ([arthurvr](https://github.com/arthurvr))
|
||||
|
||||
- Add awesome-vagrant [\#57](https://github.com/sindresorhus/awesome/pull/57) ([arthurvr](https://github.com/arthurvr))
|
||||
|
||||
- Add awesome-backbone [\#56](https://github.com/sindresorhus/awesome/pull/56) ([arthurvr](https://github.com/arthurvr))
|
||||
|
||||
- Add continuous integration tools [\#50](https://github.com/sindresorhus/awesome/pull/50) ([itech001](https://github.com/itech001))
|
||||
|
||||
- Add public datasets repository. [\#49](https://github.com/sindresorhus/awesome/pull/49) ([caesar0301](https://github.com/caesar0301))
|
||||
|
||||
- added awesome machine learning [\#47](https://github.com/sindresorhus/awesome/pull/47) ([7c00](https://github.com/7c00))
|
||||
|
||||
- Added awesome Symfony2 [\#45](https://github.com/sindresorhus/awesome/pull/45) ([eriwin](https://github.com/eriwin))
|
||||
|
||||
- awesome-pcaptools for network traffic processing added to awesome list. [\#44](https://github.com/sindresorhus/awesome/pull/44) ([caesar0301](https://github.com/caesar0301))
|
||||
|
||||
- awesome-dojo added to the web platforms [\#43](https://github.com/sindresorhus/awesome/pull/43) ([peterkokot](https://github.com/peterkokot))
|
||||
|
||||
- adding knockoutJS [\#40](https://github.com/sindresorhus/awesome/pull/40) ([dnbard](https://github.com/dnbard))
|
||||
|
||||
- Awesome SQLAlchemy [\#39](https://github.com/sindresorhus/awesome/pull/39) ([dahlia](https://github.com/dahlia))
|
||||
|
||||
- Awesome Docker [\#38](https://github.com/sindresorhus/awesome/pull/38) ([veggiemonk](https://github.com/veggiemonk))
|
||||
|
||||
- Add awesome-svg link to the list [\#36](https://github.com/sindresorhus/awesome/pull/36) ([willianjusten](https://github.com/willianjusten))
|
||||
|
||||
- Added awesome radio [\#35](https://github.com/sindresorhus/awesome/pull/35) ([niclashoyer](https://github.com/niclashoyer))
|
||||
|
||||
- Added Awesome-Styleguides [\#30](https://github.com/sindresorhus/awesome/pull/30) ([RichardLitt](https://github.com/RichardLitt))
|
||||
|
||||
- Added an awesome-conferences link [\#26](https://github.com/sindresorhus/awesome/pull/26) ([RichardLitt](https://github.com/RichardLitt))
|
||||
|
||||
- Add Dart [\#25](https://github.com/sindresorhus/awesome/pull/25) ([yissachar](https://github.com/yissachar))
|
||||
|
||||
- Add Lua [\#24](https://github.com/sindresorhus/awesome/pull/24) ([LewisJEllis](https://github.com/LewisJEllis))
|
||||
|
||||
- Add CakePHP PHP Framework. [\#22](https://github.com/sindresorhus/awesome/pull/22) ([dereuromark](https://github.com/dereuromark))
|
||||
|
||||
- Reorganized Miscellaneous section [\#21](https://github.com/sindresorhus/awesome/pull/21) ([tuwannu](https://github.com/tuwannu))
|
||||
|
||||
- Added Git Cheat Sheet [\#19](https://github.com/sindresorhus/awesome/pull/19) ([ArslanBilal](https://github.com/ArslanBilal))
|
||||
|
||||
- Add awesome selenium list [\#16](https://github.com/sindresorhus/awesome/pull/16) ([christian-bromann](https://github.com/christian-bromann))
|
||||
|
||||
- Add Magictools for Game Development [\#15](https://github.com/sindresorhus/awesome/pull/15) ([passy](https://github.com/passy))
|
||||
|
||||
- Add Haskell [\#14](https://github.com/sindresorhus/awesome/pull/14) ([csu](https://github.com/csu))
|
||||
|
||||
- Added Play1 java web framework [\#13](https://github.com/sindresorhus/awesome/pull/13) ([PerfectCarl](https://github.com/PerfectCarl))
|
||||
|
||||
- Added awesome-algorithms [\#10](https://github.com/sindresorhus/awesome/pull/10) ([tayllan](https://github.com/tayllan))
|
||||
|
||||
- Add C/C++ [\#8](https://github.com/sindresorhus/awesome/pull/8) ([fffaraz](https://github.com/fffaraz))
|
||||
|
||||
- Add "Awesome dotfiles" [\#6](https://github.com/sindresorhus/awesome/pull/6) ([webpro](https://github.com/webpro))
|
||||
|
||||
- Added Awesome Android list [\#4](https://github.com/sindresorhus/awesome/pull/4) ([JStumpp](https://github.com/JStumpp))
|
||||
|
||||
- added awesome web tool [\#3](https://github.com/sindresorhus/awesome/pull/3) ([necenzurat](https://github.com/necenzurat))
|
||||
|
||||
- Awesome cobol is probably a joke [\#2](https://github.com/sindresorhus/awesome/pull/2) ([dimlev](https://github.com/dimlev))
|
||||
|
||||
- Added awesome Scala lists [\#1](https://github.com/sindresorhus/awesome/pull/1) ([SkyRocknRoll](https://github.com/SkyRocknRoll))
|
||||
## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ module GitHubChangelogGenerator
|
|||
"This script can make only 50 requests to GitHub API per hour without token!"
|
||||
|
||||
def initialize(options = {})
|
||||
@options = options
|
||||
@options = options || {}
|
||||
|
||||
@logger = Logger.new(STDOUT)
|
||||
@logger.formatter = proc do |_severity, _datetime, _progname, msg|
|
||||
|
@ -28,8 +28,8 @@ module GitHubChangelogGenerator
|
|||
@tag_times_hash = {}
|
||||
github_options = { per_page: PER_PAGE_NUMBER }
|
||||
github_options[:oauth_token] = @github_token unless @github_token.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[:endpoint] = @options[:github_endpoint] unless @options[:github_endpoint].nil?
|
||||
github_options[:site] = @options[:github_endpoint] unless @options[:github_site].nil?
|
||||
|
||||
@github = check_github_response { Github.new github_options }
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ require "github_changelog_generator/fetcher"
|
|||
require_relative "generator_generation"
|
||||
require_relative "generator_fetcher"
|
||||
require_relative "generator_processor"
|
||||
require_relative "generator_tags"
|
||||
|
||||
module GitHubChangelogGenerator
|
||||
# Default error for ChangelogGenerator
|
||||
|
@ -17,13 +18,9 @@ module GitHubChangelogGenerator
|
|||
# generator = GitHubChangelogGenerator::Generator.new
|
||||
# content = generator.compound_changelog
|
||||
def initialize(options = nil)
|
||||
@options = options
|
||||
@options = options || {}
|
||||
|
||||
@fetcher = GitHubChangelogGenerator::Fetcher.new @options
|
||||
|
||||
fetch_tags
|
||||
|
||||
fetch_issues_and_pr
|
||||
end
|
||||
|
||||
def fetch_issues_and_pr
|
||||
|
@ -37,20 +34,6 @@ module GitHubChangelogGenerator
|
|||
detect_actual_closed_dates(@issues + @pull_requests)
|
||||
end
|
||||
|
||||
def fetch_tags
|
||||
# @all_tags = get_filtered_tags
|
||||
@all_tags = @fetcher.get_all_tags
|
||||
|
||||
fetch_tags_dates
|
||||
sort_tags_by_date
|
||||
end
|
||||
|
||||
# Sort all tags by date
|
||||
def sort_tags_by_date
|
||||
puts "Sorting tags..." if @options[:verbose]
|
||||
@all_tags.sort_by! { |x| @fetcher.get_time_of_tag(x) }.reverse!
|
||||
end
|
||||
|
||||
# Encapsulate characters to make markdown look as expected.
|
||||
#
|
||||
# @param [String] string
|
||||
|
@ -94,26 +77,6 @@ module GitHubChangelogGenerator
|
|||
log
|
||||
end
|
||||
|
||||
# Detect link, name and time for specified tag.
|
||||
#
|
||||
# @param [Hash] newer_tag newer tag. Can be nil, if it's Unreleased section.
|
||||
# @return [Array] link, name and time of the tag
|
||||
def detect_link_tag_time(newer_tag)
|
||||
# if tag is nil - set current time
|
||||
newer_tag_time = newer_tag.nil? ? Time.new : @fetcher.get_time_of_tag(newer_tag)
|
||||
|
||||
# if it's future release tag - set this value
|
||||
if newer_tag.nil? && @options[:future_release]
|
||||
newer_tag_name = @options[:future_release]
|
||||
newer_tag_link = @options[:future_release]
|
||||
else
|
||||
# put unreleased label if there is no name for the tag
|
||||
newer_tag_name = newer_tag.nil? ? @options[:unreleased_label] : newer_tag["name"]
|
||||
newer_tag_link = newer_tag.nil? ? "HEAD" : newer_tag_name
|
||||
end
|
||||
[newer_tag_link, newer_tag_name, newer_tag_time]
|
||||
end
|
||||
|
||||
# Generate ready-to-paste log from list of issues.
|
||||
#
|
||||
# @param [Array] issues
|
||||
|
|
|
@ -4,12 +4,13 @@ module GitHubChangelogGenerator
|
|||
#
|
||||
# @return [String] Generated change log file
|
||||
def compound_changelog
|
||||
fetch_and_filter_tags
|
||||
fetch_issues_and_pr
|
||||
|
||||
log = "# Change Log\n\n"
|
||||
|
||||
if @options[:unreleased_only]
|
||||
log += generate_log_between_tags(all_tags[0], nil)
|
||||
elsif @options[:tag1] && @options[:tag2]
|
||||
log = generate_for_2_tags(log)
|
||||
else
|
||||
log += generate_log_for_all_tags
|
||||
end
|
||||
|
|
|
@ -138,23 +138,6 @@ module GitHubChangelogGenerator
|
|||
filtered_issues
|
||||
end
|
||||
|
||||
# Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags
|
||||
#
|
||||
# @return [Array]
|
||||
def get_filtered_tags
|
||||
all_tags = @fetcher.get_all_tags
|
||||
filtered_tags = []
|
||||
if @options[:between_tags]
|
||||
@options[:between_tags].each do |tag|
|
||||
unless all_tags.include? tag
|
||||
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
|
||||
end
|
||||
end
|
||||
filtered_tags = all_tags.select { |tag| @options[:between_tags].include? tag }
|
||||
end
|
||||
filtered_tags
|
||||
end
|
||||
|
||||
# General filtered function
|
||||
#
|
||||
# @param [Array] all_issues
|
||||
|
|
53
lib/github_changelog_generator/generator/generator_tags.rb
Normal file
53
lib/github_changelog_generator/generator/generator_tags.rb
Normal file
|
@ -0,0 +1,53 @@
|
|||
module GitHubChangelogGenerator
|
||||
class Generator
|
||||
# fetch, filter tags, fetch dates and sort them in time order
|
||||
def fetch_and_filter_tags
|
||||
@all_tags = get_filtered_tags(@fetcher.get_all_tags)
|
||||
fetch_tags_dates
|
||||
sort_tags_by_date
|
||||
end
|
||||
|
||||
# Sort all tags by date
|
||||
def sort_tags_by_date
|
||||
puts "Sorting tags..." if @options[:verbose]
|
||||
@all_tags.sort_by! { |x| @fetcher.get_time_of_tag(x) }.reverse!
|
||||
end
|
||||
|
||||
# Detect link, name and time for specified tag.
|
||||
#
|
||||
# @param [Hash] newer_tag newer tag. Can be nil, if it's Unreleased section.
|
||||
# @return [Array] link, name and time of the tag
|
||||
def detect_link_tag_time(newer_tag)
|
||||
# if tag is nil - set current time
|
||||
newer_tag_time = newer_tag.nil? ? Time.new : @fetcher.get_time_of_tag(newer_tag)
|
||||
|
||||
# if it's future release tag - set this value
|
||||
if newer_tag.nil? && @options[:future_release]
|
||||
newer_tag_name = @options[:future_release]
|
||||
newer_tag_link = @options[:future_release]
|
||||
else
|
||||
# put unreleased label if there is no name for the tag
|
||||
newer_tag_name = newer_tag.nil? ? @options[:unreleased_label] : newer_tag["name"]
|
||||
newer_tag_link = newer_tag.nil? ? "HEAD" : newer_tag_name
|
||||
end
|
||||
[newer_tag_link, newer_tag_name, newer_tag_time]
|
||||
end
|
||||
|
||||
# Return tags after filtering tags in lists provided by option: --between-tags & --exclude-tags
|
||||
#
|
||||
# @return [Array]
|
||||
def get_filtered_tags(all_tags)
|
||||
all_tags = all_tags
|
||||
filtered_tags = all_tags
|
||||
if @options[:between_tags]
|
||||
@options[:between_tags].each do |tag|
|
||||
unless all_tags.include? tag
|
||||
puts "Warning: can't find tag #{tag}, specified with --between-tags option.".yellow
|
||||
end
|
||||
end
|
||||
filtered_tags = all_tags.select { |tag| @options[:between_tags].include? tag }
|
||||
end
|
||||
filtered_tags
|
||||
end
|
||||
end
|
||||
end
|
|
@ -5,34 +5,32 @@ require_relative "version"
|
|||
|
||||
module GitHubChangelogGenerator
|
||||
class Parser
|
||||
# parse options with optparse
|
||||
def self.parse_options
|
||||
options = {
|
||||
tag1: nil,
|
||||
tag2: nil,
|
||||
date_format: "%Y-%m-%d",
|
||||
output: "CHANGELOG.md",
|
||||
issues: true,
|
||||
add_issues_wo_labels: true,
|
||||
add_pr_wo_labels: true,
|
||||
pulls: true,
|
||||
filter_issues_by_milestone: true,
|
||||
author: true,
|
||||
unreleased: true,
|
||||
unreleased_label: "Unreleased",
|
||||
compare_link: true,
|
||||
include_labels: %w(bug enhancement),
|
||||
exclude_labels: %w(duplicate question invalid wontfix),
|
||||
max_issues: nil,
|
||||
simple_list: false,
|
||||
verbose: true,
|
||||
options = get_default_options
|
||||
|
||||
merge_prefix: "**Merged pull requests:**",
|
||||
issue_prefix: "**Closed issues:**",
|
||||
bug_prefix: "**Fixed bugs:**",
|
||||
enhancement_prefix: "**Implemented enhancements:**",
|
||||
git_remote: "origin"
|
||||
}
|
||||
parser = setup_parser(options)
|
||||
|
||||
parser.parse!
|
||||
|
||||
detect_user_and_project(options)
|
||||
|
||||
if !options[:user] || !options[:project]
|
||||
puts parser.banner
|
||||
exit
|
||||
end
|
||||
|
||||
if options[:verbose]
|
||||
puts "Performing task with options:"
|
||||
pp options
|
||||
puts ""
|
||||
end
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
# setup parsing options
|
||||
def self.setup_parser(options)
|
||||
parser = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: github_changelog_generator [options]"
|
||||
opts.on("-u", "--user [USER]", "Username of the owner of target GitHub repo") do |last|
|
||||
|
@ -86,6 +84,9 @@ module GitHubChangelogGenerator
|
|||
opts.on("--exclude-labels x,y,z", Array, 'Issues with the specified labels will be always excluded from changelog. Default is \'duplicate,question,invalid,wontfix\'') do |list|
|
||||
options[:exclude_labels] = list
|
||||
end
|
||||
opts.on("--between-tags x,y,z", Array, "Change log will be filed only between specified tags") do |list|
|
||||
options[:between_tags] = list
|
||||
end
|
||||
opts.on("--max-issues [NUMBER]", Integer, "Max number of issues to fetch from GitHub. Default is unlimited") do |max|
|
||||
options[:max_issues] = max
|
||||
end
|
||||
|
@ -113,25 +114,41 @@ module GitHubChangelogGenerator
|
|||
exit
|
||||
end
|
||||
end
|
||||
parser
|
||||
end
|
||||
|
||||
parser.parse!
|
||||
|
||||
detect_user_and_project(options)
|
||||
|
||||
if !options[:user] || !options[:project]
|
||||
puts parser.banner
|
||||
exit
|
||||
end
|
||||
|
||||
if options[:verbose]
|
||||
puts "Performing task with options:"
|
||||
pp options
|
||||
puts ""
|
||||
end
|
||||
# just get default options
|
||||
def self.get_default_options
|
||||
options = {
|
||||
tag1: nil,
|
||||
tag2: nil,
|
||||
date_format: "%Y-%m-%d",
|
||||
output: "CHANGELOG.md",
|
||||
issues: true,
|
||||
add_issues_wo_labels: true,
|
||||
add_pr_wo_labels: true,
|
||||
pulls: true,
|
||||
filter_issues_by_milestone: true,
|
||||
author: true,
|
||||
unreleased: true,
|
||||
unreleased_label: "Unreleased",
|
||||
compare_link: true,
|
||||
include_labels: %w(bug enhancement),
|
||||
exclude_labels: %w(duplicate question invalid wontfix),
|
||||
max_issues: nil,
|
||||
simple_list: false,
|
||||
verbose: true,
|
||||
merge_prefix: "**Merged pull requests:**",
|
||||
issue_prefix: "**Closed issues:**",
|
||||
bug_prefix: "**Fixed bugs:**",
|
||||
enhancement_prefix: "**Implemented enhancements:**",
|
||||
git_remote: "origin"
|
||||
}
|
||||
|
||||
options
|
||||
end
|
||||
|
||||
# Detects user and project from git
|
||||
def self.detect_user_and_project(options)
|
||||
options[:user], options[:project] = user_project_from_option(ARGV[0], ARGV[1], options[:github_site])
|
||||
if !options[:user] || !options[:project]
|
||||
|
|
29
spec/unit/generator/generator_tags_spec.rb
Normal file
29
spec/unit/generator/generator_tags_spec.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
describe GitHubChangelogGenerator::Generator do
|
||||
describe "#get_filtered_tags" do
|
||||
before(:all) do
|
||||
@generator = GitHubChangelogGenerator::Generator.new
|
||||
end
|
||||
|
||||
context "when between_tags nil" do
|
||||
# before(:each) do
|
||||
# @generator.options = {}
|
||||
# end
|
||||
subject { @generator.get_filtered_tags(%w(1 2 3)) }
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(%w(1 2 3)) }
|
||||
end
|
||||
|
||||
context "when between_tags 1" do
|
||||
# before(:each) do
|
||||
# @generator.options = {between_tags: ["1"]}
|
||||
# end
|
||||
|
||||
subject do
|
||||
@generator.instance_variable_set("@options", between_tags: ["1"])
|
||||
@generator.get_filtered_tags(%w(1 2 3))
|
||||
end
|
||||
it { is_expected.to be_a(Array) }
|
||||
it { is_expected.to match_array(%w(1)) }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user