Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e139f839c9 | ||
|
|
a7a75a181e | ||
|
|
6efa421816 | ||
|
|
e8d59fe66a | ||
|
|
6b5cf5ab2e | ||
|
|
de6763aa3a | ||
|
|
5f019482d2 | ||
|
|
6da115c4b0 | ||
|
|
657ce0e838 | ||
|
|
5304e4faf8 | ||
|
|
e6bb728355 | ||
|
|
135c48a494 | ||
|
|
6bad92e899 | ||
|
|
ad4c20d8d8 | ||
|
|
a5d9766aef | ||
|
|
a0cfaa66a2 | ||
|
|
d16f4f7cb5 | ||
|
|
1d6d6ab400 | ||
|
|
5b07fc9614 | ||
|
|
3437fbf278 | ||
|
|
ba4db0e5f4 | ||
|
|
abac1013f1 | ||
|
|
28247edc7f |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -1,5 +1,21 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [1.2.4] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.4)
|
||||||
|
#### 16/12/14
|
||||||
|
- *Merged pull-request:* Fix crash when user is NULL [\#40](https://github.com/skywinder/Github-Changelog-Generator/pull/40) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
|
- *Merged pull-request:* Implement async fetching [\#39](https://github.com/skywinder/Github-Changelog-Generator/pull/39) ([skywinder](https://github.com/skywinder))
|
||||||
|
|
||||||
|
- *Implemented enhancement:* Add ability to run with one parameter instead -u -p [\#38](https://github.com/skywinder/Github-Changelog-Generator/issues/38)
|
||||||
|
|
||||||
|
- *Implemented enhancement:* Detailed output [\#33](https://github.com/skywinder/Github-Changelog-Generator/issues/33)
|
||||||
|
|
||||||
|
- *Fixed bug:* Docs lacking or basic behavior not as advertised [\#30](https://github.com/skywinder/Github-Changelog-Generator/issues/30)
|
||||||
|
|
||||||
|
## [1.2.3] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.3)
|
||||||
|
#### 16/12/14
|
||||||
|
- *Fixed bug:* Encapsulate \[ \> \* \_ \ \] signs in issues names [\#34](https://github.com/skywinder/Github-Changelog-Generator/issues/34)
|
||||||
|
|
||||||
## [1.2.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2)
|
## [1.2.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.2)
|
||||||
#### 10/12/14
|
#### 10/12/14
|
||||||
- *Merged pull-request:* Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
|
- *Merged pull-request:* Add a Bitdeli Badge to README [\#36](https://github.com/skywinder/Github-Changelog-Generator/pull/36) ([bitdeli-chef](https://github.com/bitdeli-chef))
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
github_token
|
github_token
|
||||||
|
|
||||||
if @github_token.nil?
|
github_options = {per_page: PER_PAGE_NUMBER}
|
||||||
@github = Github.new per_page: PER_PAGE_NUMBER
|
github_options[:oauth_token] = @github_token unless @github_token.nil?
|
||||||
else
|
github_options[:endpoint] = options[:github_endpoint] unless options[:github_endpoint].nil?
|
||||||
@github = Github.new oauth_token: @github_token,
|
github_options[:site] = options[:github_endpoint] unless options[:github_site].nil?
|
||||||
per_page: PER_PAGE_NUMBER
|
|
||||||
end
|
@github = Github.new github_options
|
||||||
|
|
||||||
@generator = Generator.new(@options)
|
@generator = Generator.new(@options)
|
||||||
|
|
||||||
@@ -231,6 +231,11 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
def generate_log_between_tags(older_tag, newer_tag)
|
def generate_log_between_tags(older_tag, newer_tag)
|
||||||
|
|
||||||
|
if newer_tag.nil?
|
||||||
|
puts "Can't find tag -> terminate"
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
|
||||||
newer_tag_time = self.get_time_of_tag(newer_tag)
|
newer_tag_time = self.get_time_of_tag(newer_tag)
|
||||||
newer_tag_name = newer_tag['name']
|
newer_tag_name = newer_tag['name']
|
||||||
|
|
||||||
@@ -243,6 +248,43 @@ module GitHubChangelogGenerator
|
|||||||
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
|
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if @options[:filter_issues_by_milestone]
|
||||||
|
#delete excess irrelevant issues (according milestones)
|
||||||
|
filtered_issues.select! { |issue|
|
||||||
|
if issue.milestone.nil?
|
||||||
|
true
|
||||||
|
else
|
||||||
|
#check, that this milestone in tag list:
|
||||||
|
milestone_is_tag = @all_tags.find { |tag|
|
||||||
|
tag.name == issue.milestone.title
|
||||||
|
}
|
||||||
|
milestone_is_tag.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#add missed issues (according milestones)
|
||||||
|
issues_to_add = @issues.select { |issue|
|
||||||
|
if issue.milestone.nil?
|
||||||
|
false
|
||||||
|
else
|
||||||
|
#check, that this milestone in tag list:
|
||||||
|
milestone_is_tag = @all_tags.find { |tag|
|
||||||
|
tag.name == issue.milestone.title
|
||||||
|
}
|
||||||
|
|
||||||
|
if milestone_is_tag.nil?
|
||||||
|
false
|
||||||
|
else
|
||||||
|
issue.milestone.title == newer_tag_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
filtered_issues |= issues_to_add
|
||||||
|
end
|
||||||
|
|
||||||
self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time)
|
self.create_log(filtered_pull_requests, filtered_issues, newer_tag_name, newer_tag_time)
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -276,8 +318,10 @@ module GitHubChangelogGenerator
|
|||||||
# @return [String]
|
# @return [String]
|
||||||
def create_log(pull_requests, issues, tag_name, tag_time)
|
def create_log(pull_requests, issues, tag_name, tag_time)
|
||||||
|
|
||||||
|
github_site = options[:github_site] || 'https://github.com'
|
||||||
|
|
||||||
# Generate tag name and link
|
# Generate tag name and link
|
||||||
log = "## [#{tag_name}] (https://github.com/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
|
log = "## [#{tag_name}] (#{github_site}/#{@options[:user]}/#{@options[:project]}/tree/#{tag_name})\n"
|
||||||
|
|
||||||
#Generate date string:
|
#Generate date string:
|
||||||
time_string = tag_time.strftime @options[:format]
|
time_string = tag_time.strftime @options[:format]
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
||||||
if @options[:author]
|
if @options[:author]
|
||||||
if !pull_request.user.nil?
|
if pull_request.user.nil?
|
||||||
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
|
||||||
else
|
|
||||||
merge += " ({Null user})\n\n"
|
merge += " ({Null user})\n\n"
|
||||||
|
else
|
||||||
|
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
merge += "\n\n"
|
merge += "\n\n"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'PP'
|
require 'pp'
|
||||||
require_relative 'version'
|
require_relative 'version'
|
||||||
|
|
||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
class Parser
|
class Parser
|
||||||
def self.parse_options
|
def self.parse_options
|
||||||
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil}
|
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md', :labels => %w(bug enhancement), :pulls => true, :issues => true, :verbose => true, :add_issues_wo_labels => true, :merge_prefix => '*Merged pull-request:* ', :author => true, :pull_request_labels => nil, :filter_issues_by_milestone => true}
|
||||||
|
|
||||||
parser = OptionParser.new { |opts|
|
parser = OptionParser.new { |opts|
|
||||||
opts.banner = 'Usage: changelog_generator [options]'
|
opts.banner = 'Usage: changelog_generator [options]'
|
||||||
@@ -37,6 +37,9 @@ module GitHubChangelogGenerator
|
|||||||
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
|
opts.on('--[no-]pull-requests', 'Include pull-requests to changelog. Default is true') do |v|
|
||||||
options[:pulls] = v
|
options[:pulls] = v
|
||||||
end
|
end
|
||||||
|
opts.on('--[no-]filter-issues-by-milestone', 'Use milestone to detect when issue was resolved. Default is true') do |last|
|
||||||
|
options[:filter_issues_by_milestone] = last
|
||||||
|
end
|
||||||
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[:last] = author
|
options[:last] = author
|
||||||
end
|
end
|
||||||
@@ -46,6 +49,12 @@ module GitHubChangelogGenerator
|
|||||||
opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list|
|
opts.on('--labels-pr x,y,z', Array, 'Only pull requests with specified labels will be included to changelog. Default is nil') do |list|
|
||||||
options[:pull_request_labels] = list
|
options[:pull_request_labels] = list
|
||||||
end
|
end
|
||||||
|
opts.on('--github-site [URL]', 'The Enterprise Github site on which your project is hosted.') do |last|
|
||||||
|
options[:github_site] = last
|
||||||
|
end
|
||||||
|
opts.on('--github-api [URL]', 'The enterprise endpoint to use for your Github API.') do |last|
|
||||||
|
options[:github_endpoint] = last
|
||||||
|
end
|
||||||
opts.on('-v', '--version', 'Print version number') do |v|
|
opts.on('-v', '--version', 'Print version number') do |v|
|
||||||
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
||||||
exit
|
exit
|
||||||
@@ -59,8 +68,9 @@ module GitHubChangelogGenerator
|
|||||||
parser.parse!
|
parser.parse!
|
||||||
|
|
||||||
if ARGV[0] && !ARGV[1]
|
if ARGV[0] && !ARGV[1]
|
||||||
|
github_site = options[:github_site] ? options[:github_site] : 'github.com'
|
||||||
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name
|
# this match should parse https://github.com/skywinder/Github-Changelog-Generator and skywinder/Github-Changelog-Generator to user and name
|
||||||
match = /(?:.+github\.com\/)?(.+)\/(.+)/.match(ARGV[0])
|
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])
|
||||||
|
|
||||||
if match[2].nil?
|
if match[2].nil?
|
||||||
exit
|
exit
|
||||||
@@ -72,7 +82,7 @@ module GitHubChangelogGenerator
|
|||||||
|
|
||||||
if !options[:user] && !options[:project]
|
if !options[:user] && !options[:project]
|
||||||
remote = `git remote -vv`.split("\n")
|
remote = `git remote -vv`.split("\n")
|
||||||
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git)?.*/.match(remote[0])
|
match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)?(?:\.git).*/.match(remote[0])
|
||||||
|
|
||||||
if match && match[1] && match[2]
|
if match && match[1] && match[2]
|
||||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||||
@@ -94,4 +104,4 @@ module GitHubChangelogGenerator
|
|||||||
options
|
options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
module GitHubChangelogGenerator
|
module GitHubChangelogGenerator
|
||||||
VERSION = '1.2.3'
|
VERSION = '1.2.5'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user