Compare commits
50 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 | ||
|
|
fcc1c608a2 | ||
|
|
46ae40f250 | ||
|
|
00f98b8ca6 | ||
|
|
5da838efee | ||
|
|
73b789ab82 | ||
|
|
b5778b14a0 | ||
|
|
e29ff3c3a9 | ||
|
|
9646b49add | ||
|
|
a44b0bdd25 | ||
|
|
433d46d85b | ||
|
|
950e8916d9 | ||
|
|
87c6e33335 | ||
|
|
4488ac8cc6 | ||
|
|
c697c6be4a | ||
|
|
69dd5eadc2 | ||
|
|
4ea1058cd5 | ||
|
|
fcd78e6bc4 | ||
|
|
e6c0d49200 | ||
|
|
0f5db97474 | ||
|
|
0901b38577 | ||
|
|
2a24f49a83 | ||
|
|
2ad014d5c7 | ||
|
|
188ba7e073 | ||
|
|
6f53fe0a1d | ||
|
|
2c7853cf9f | ||
|
|
6830ea49f2 | ||
|
|
5be1a2afaf |
30
CHANGELOG.md
30
CHANGELOG.md
@@ -1,5 +1,25 @@
|
||||
# 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)
|
||||
#### 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))
|
||||
|
||||
## [1.2.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.1)
|
||||
#### 22/11/14
|
||||
- *Merged pull-request:* Issues for last tag not in list [\#29](https://github.com/skywinder/Github-Changelog-Generator/pull/29) ([skywinder](https://github.com/skywinder))
|
||||
@@ -8,11 +28,11 @@
|
||||
|
||||
## [1.2.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.2.0)
|
||||
#### 19/11/14
|
||||
- *Merged pull-request:* Add filter for pull-requests labels. (option --filter-pull-requests) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
|
||||
- *Merged pull-request:* Add filter for pull-requests labels. \(option --filter-pull-requests\) [\#27](https://github.com/skywinder/Github-Changelog-Generator/pull/27) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- *Merged pull-request:* Test Pull-Request [\#26](https://github.com/skywinder/Github-Changelog-Generator/pull/26) ([skywinder](https://github.com/skywinder))
|
||||
- *Merged pull-request:* Test Pull-Request SHOULD NOT APPEAR IN LOG! [\#26](https://github.com/skywinder/Github-Changelog-Generator/pull/26) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- *Merged pull-request:* Add ability to insert authors of pull-requests (--[no-]author option) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder))
|
||||
- *Merged pull-request:* Add ability to insert authors of pull-requests \(--\[no-\]author option\) [\#25](https://github.com/skywinder/Github-Changelog-Generator/pull/25) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- *Merged pull-request:* Don't receive issues in case of --no-isses flag specied [\#24](https://github.com/skywinder/Github-Changelog-Generator/pull/24) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
@@ -20,7 +40,7 @@
|
||||
#### 18/11/14
|
||||
- *Merged pull-request:* Sort tags by date [\#23](https://github.com/skywinder/Github-Changelog-Generator/pull/23) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- *Implemented enhancement:* Implement ability to retrieve GitHub token from ENV variable (to not put it to script directly) [\#19](https://github.com/skywinder/Github-Changelog-Generator/issues/19)
|
||||
- *Implemented enhancement:* Implement ability to retrieve GitHub token from ENV variable \(to not put it to script directly\) [\#19](https://github.com/skywinder/Github-Changelog-Generator/issues/19)
|
||||
|
||||
- *Fixed bug:* Script fills changelog only for first 30 tags. [\#20](https://github.com/skywinder/Github-Changelog-Generator/issues/20)
|
||||
|
||||
@@ -66,7 +86,7 @@
|
||||
#### 07/11/14
|
||||
- *Merged pull-request:* Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
- *Merged pull-request:* Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
|
||||
- *Merged pull-request:* Add option \(-o --output\) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1) ([skywinder](https://github.com/skywinder))
|
||||
|
||||
## [0.0.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.2)
|
||||
#### 06/11/14
|
||||
|
||||
@@ -2,7 +2,7 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
addressable (2.3.6)
|
||||
colorize (0.7.3)
|
||||
colorize (0.7.4)
|
||||
descendants_tracker (0.0.4)
|
||||
thread_safe (~> 0.3, >= 0.3.1)
|
||||
faraday (0.9.0)
|
||||
@@ -15,13 +15,13 @@ GEM
|
||||
multi_json (>= 1.7.5, < 2.0)
|
||||
nokogiri (~> 1.6.3)
|
||||
oauth2
|
||||
hashie (3.3.1)
|
||||
jwt (1.0.0)
|
||||
hashie (3.3.2)
|
||||
jwt (1.2.0)
|
||||
mini_portile (0.6.1)
|
||||
multi_json (1.10.1)
|
||||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
nokogiri (1.6.4)
|
||||
nokogiri (1.6.5)
|
||||
mini_portile (~> 0.6.0)
|
||||
oauth2 (1.0.0)
|
||||
faraday (>= 0.8, < 0.10)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
require 'github_api'
|
||||
require 'json'
|
||||
require 'colorize'
|
||||
require 'benchmark'
|
||||
|
||||
require_relative 'github_changelog_generator/parser'
|
||||
require_relative 'github_changelog_generator/generator'
|
||||
require_relative 'github_changelog_generator/version'
|
||||
@@ -12,6 +14,8 @@ module GitHubChangelogGenerator
|
||||
|
||||
attr_accessor :options, :all_tags, :github
|
||||
|
||||
PER_PAGE_NUMBER = 30
|
||||
|
||||
def initialize
|
||||
|
||||
@options = Parser.parse_options
|
||||
@@ -24,11 +28,12 @@ module GitHubChangelogGenerator
|
||||
|
||||
github_token
|
||||
|
||||
if @github_token.nil?
|
||||
@github = Github.new
|
||||
else
|
||||
@github = Github.new oauth_token: @github_token
|
||||
end
|
||||
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 = Github.new github_options
|
||||
|
||||
@generator = Generator.new(@options)
|
||||
|
||||
@@ -56,18 +61,23 @@ module GitHubChangelogGenerator
|
||||
def get_all_closed_pull_requests
|
||||
|
||||
if @options[:verbose]
|
||||
puts 'Fetching pull requests..'
|
||||
print "Fetching pull requests...\r"
|
||||
end
|
||||
|
||||
response = @github.pull_requests.list @options[:user], @options[:project], :state => 'closed'
|
||||
|
||||
pull_requests = []
|
||||
page_i = 0
|
||||
response.each_page do |page|
|
||||
page_i += PER_PAGE_NUMBER
|
||||
print "Fetching pull requests... #{page_i}\r"
|
||||
pull_requests.concat(page)
|
||||
end
|
||||
|
||||
print "\r"
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Received all closed pull requests: #{pull_requests.count}"
|
||||
puts "Received closed pull requests: #{pull_requests.count}"
|
||||
end
|
||||
|
||||
unless @options[:pull_request_labels].nil?
|
||||
@@ -148,8 +158,13 @@ module GitHubChangelogGenerator
|
||||
|
||||
def generate_log_for_all_tags
|
||||
log = ''
|
||||
@all_tags.each { |tag| self.get_time_of_tag(tag) }
|
||||
|
||||
# Async fetching tags:
|
||||
threads = []
|
||||
@all_tags.each { |tag|
|
||||
threads << Thread.new { self.get_time_of_tag(tag) }
|
||||
}
|
||||
threads.each { |thr| thr.join }
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Sorting tags.."
|
||||
@@ -177,16 +192,19 @@ module GitHubChangelogGenerator
|
||||
def get_all_tags
|
||||
|
||||
if @options[:verbose]
|
||||
puts 'Fetching all tags..'
|
||||
print "Fetching tags...\r"
|
||||
end
|
||||
|
||||
response = @github.repos.tags @options[:user], @options[:project]
|
||||
|
||||
tags = []
|
||||
page_i = 0
|
||||
response.each_page do |page|
|
||||
page_i += PER_PAGE_NUMBER
|
||||
print "Fetching tags... #{page_i}\r"
|
||||
tags.concat(page)
|
||||
end
|
||||
|
||||
print "\r"
|
||||
if @options[:verbose]
|
||||
puts "Found #{tags.count} tags"
|
||||
end
|
||||
@@ -213,6 +231,11 @@ module GitHubChangelogGenerator
|
||||
|
||||
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_name = newer_tag['name']
|
||||
|
||||
@@ -225,6 +248,43 @@ module GitHubChangelogGenerator
|
||||
filtered_issues = delete_by_time(@issues, :closed_at, newer_tag_time, older_tag_time)
|
||||
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)
|
||||
|
||||
end
|
||||
@@ -258,8 +318,10 @@ module GitHubChangelogGenerator
|
||||
# @return [String]
|
||||
def create_log(pull_requests, issues, tag_name, tag_time)
|
||||
|
||||
github_site = options[:github_site] || 'https://github.com'
|
||||
|
||||
# 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:
|
||||
time_string = tag_time.strftime @options[:format]
|
||||
@@ -329,10 +391,6 @@ module GitHubChangelogGenerator
|
||||
return @tag_times_hash[prev_tag['name']]
|
||||
end
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Getting time for tag #{prev_tag['name']}"
|
||||
end
|
||||
|
||||
github_git_data_commits_get = @github.git_data.commits.get @options[:user], @options[:project], prev_tag['commit']['sha']
|
||||
time_string = github_git_data_commits_get['committer']['date']
|
||||
Time.parse(time_string)
|
||||
@@ -341,13 +399,22 @@ module GitHubChangelogGenerator
|
||||
|
||||
def get_all_issues
|
||||
|
||||
if @options[:verbose]
|
||||
print "Fetching closed issues...\r"
|
||||
end
|
||||
|
||||
response = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil
|
||||
|
||||
issues = []
|
||||
page_i = 0
|
||||
response.each_page do |page|
|
||||
page_i += PER_PAGE_NUMBER
|
||||
print "Fetching closed issues... #{page_i}\r"
|
||||
issues.concat(page)
|
||||
end
|
||||
|
||||
print "\r"
|
||||
|
||||
# remove pull request from issues:
|
||||
issues.select! { |x|
|
||||
x.pull_request == nil
|
||||
@@ -357,6 +424,11 @@ module GitHubChangelogGenerator
|
||||
puts "Received closed issues: #{issues.count}"
|
||||
end
|
||||
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Filtering issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}"
|
||||
end
|
||||
|
||||
filtered_issues = issues.select { |issue|
|
||||
#compare is there any labels from @options[:labels] array
|
||||
(issue.labels.map { |label| label.name } & @options[:labels]).any?
|
||||
@@ -371,7 +443,7 @@ module GitHubChangelogGenerator
|
||||
end
|
||||
|
||||
if @options[:verbose]
|
||||
puts "Filter issues with labels #{@options[:labels]}#{@options[:add_issues_wo_labels] ? ' and w/o labels' : ''}: #{filtered_issues.count} issues"
|
||||
puts "Filtered issues: #{filtered_issues.count}"
|
||||
end
|
||||
|
||||
filtered_issues
|
||||
|
||||
@@ -10,7 +10,11 @@ module GitHubChangelogGenerator
|
||||
|
||||
merge = "#{@options[:merge_prefix]}#{encapsulated_title} [\\##{pull_request[:number]}](#{pull_request.html_url})"
|
||||
if @options[:author]
|
||||
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
||||
if pull_request.user.nil?
|
||||
merge += " ({Null user})\n\n"
|
||||
else
|
||||
merge += " ([#{pull_request.user.login}](#{pull_request.user.html_url}))\n\n"
|
||||
end
|
||||
else
|
||||
merge += "\n\n"
|
||||
end
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'optparse'
|
||||
require 'PP'
|
||||
require 'pp'
|
||||
require_relative 'version'
|
||||
|
||||
module GitHubChangelogGenerator
|
||||
class Parser
|
||||
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|
|
||||
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|
|
||||
options[:pulls] = v
|
||||
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|
|
||||
options[:last] = author
|
||||
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|
|
||||
options[:pull_request_labels] = list
|
||||
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|
|
||||
puts "Version: #{GitHubChangelogGenerator::VERSION}"
|
||||
exit
|
||||
@@ -58,15 +67,22 @@ module GitHubChangelogGenerator
|
||||
|
||||
parser.parse!
|
||||
|
||||
#udefined case with 1 parameter:
|
||||
if ARGV[0] && !ARGV[1]
|
||||
puts parser.banner
|
||||
exit
|
||||
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
|
||||
match = /(?:.+#{Regexp.escape(github_site)}\/)?(.+)\/(.+)/.match(ARGV[0])
|
||||
|
||||
if match[2].nil?
|
||||
exit
|
||||
else
|
||||
options[:user] = match[1]
|
||||
options[:project]= match[2]
|
||||
end
|
||||
end
|
||||
|
||||
if !options[:user] && !options[:project]
|
||||
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]
|
||||
puts "Detected user:#{match[1]}, project:#{match[2]}"
|
||||
@@ -83,7 +99,6 @@ module GitHubChangelogGenerator
|
||||
if ARGV[1]
|
||||
options[:tag1] = ARGV[0]
|
||||
options[:tag2] = ARGV[1]
|
||||
|
||||
end
|
||||
|
||||
options
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module GitHubChangelogGenerator
|
||||
VERSION = '1.2.2'
|
||||
VERSION = '1.2.5'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user