Skip to content

Sort issues by tags #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,48 @@

## [1.1.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.1.0)
#### 10/11/14
- *Implemented enhancement:* Detect username and project form origin [\#11](https://github.com/skywinder/Github-Changelog-Generator/issues/11)

- *Fixed bug:* Markdown formating in the last line wrong [\#9](https://github.com/skywinder/Github-Changelog-Generator/issues/9)

- *Implemented enhancement:* Detect username and project form origin [\#11](https://github.com/skywinder/Github-Changelog-Generator/issues/11)
- *Fixed bug:* Bug with wrong credentials in 1.0.1 [\#12](https://github.com/skywinder/Github-Changelog-Generator/issues/12)

## [1.0.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.1)
#### 10/11/14
- Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8)
- *Merged pull-request:* Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8)

- *Implemented enhancement:* Implement support of different tags. [\#8](https://github.com/skywinder/Github-Changelog-Generator/pull/8)

## [1.0.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/1.0.0)
#### 07/11/14
- Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7)

- Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3)
- *Merged pull-request:* Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7)

- *Fixed bug:* Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)
- *Merged pull-request:* Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3)

- *Implemented enhancement:* Add support for fixed issues and implemented enchanments. [\#6](https://github.com/skywinder/Github-Changelog-Generator/issues/6)

- *Implemented enhancement:* Implement option to specify output filename [\#4](https://github.com/skywinder/Github-Changelog-Generator/issues/4)

- *Fixed bug:* Last tag not appeared in changelog [\#5](https://github.com/skywinder/Github-Changelog-Generator/issues/5)

- *Closed issue:* Add support for issues in CHANGELOG [\#7](https://github.com/skywinder/Github-Changelog-Generator/pull/7)

- *Closed issue:* Fix parsing date of pull request [\#3](https://github.com/skywinder/Github-Changelog-Generator/pull/3)

## [0.1.0] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.1.0)
#### 07/11/14
- Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2)
- *Merged pull-request:* Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2)

- *Merged pull-request:* Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1)

- *Closed issue:* Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1)

- Add option (-o --output) to specify name of the output file. [\#1](https://github.com/skywinder/Github-Changelog-Generator/pull/1)
- *Closed issue:* Add changelog generation for last tag [\#2](https://github.com/skywinder/Github-Changelog-Generator/pull/2)

## [0.0.2] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.2)
#### 06/11/14
## [0.0.1] (https://github.com/skywinder/Github-Changelog-Generator/tree/0.0.1)
#### 06/11/14


* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
\* *This changelog was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
65 changes: 39 additions & 26 deletions lib/github_changelog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def create_log(pull_requests, issues, tag_name, tag_time)
# Generate pull requests:
if pull_requests
pull_requests.each { |dict|
merge = "#{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/pull/#{dict[:number]})\n\n"
merge = "#{@options[:merge_prefix]}#{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
log += "- #{merge}"
}
end
Expand All @@ -237,34 +237,47 @@ def create_log(pull_requests, issues, tag_name, tag_time)
if @options[:issues]
# Generate issues:
if issues
issues.each { |dict|
is_bug = false
is_enhancement = false
dict.labels.each { |label|
if label.name == 'bug'
is_bug = true
issues.sort! { |x, y|
if x.labels.any? && y.labels.any?
x.labels[0].name <=> y.labels[0].name
else
if x.labels.any?
1
else
if y.labels.any?
-1
else
0
end
end
if label.name == 'enhancement'
is_enhancement = true
end
}

intro = 'Closed issue'
if is_bug
intro = 'Fixed bug'
end

if is_enhancement
intro = 'Implemented enhancement'
}.reverse!
end
issues.each { |dict|
is_bug = false
is_enhancement = false
dict.labels.each { |label|
if label.name == 'bug'
is_bug = true
end
if label.name == 'enhancement'
is_enhancement = true
end

merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](https://github.com/#{@options[:user]}/#{@options[:project]}/issues/#{dict[:number]})\n\n"
log += "- #{merge}"
}
end

end
intro = 'Closed issue'
if is_bug
intro = 'Fixed bug'
end

if is_enhancement
intro = 'Implemented enhancement'
end

merge = "*#{intro}:* #{dict[:title]} [\\##{dict[:number]}](#{dict.html_url})\n\n"
log += "- #{merge}"
}
end
log
end

Expand All @@ -290,12 +303,12 @@ def get_all_issues
issues_req = @github.issues.list user: @options[:user], repo: @options[:project], state: 'closed', filter: 'all', labels: nil

filtered_issues = issues_req.body.select { |issues|
(issues.labels.map { |issue| issue.name} & @options[:labels]).any?
}
(issues.labels.map { |issue| issue.name } & @options[:labels]).any?
}

if @options[:add_issues_wo_labels]
issues_wo_labels = issues_req.body.select {
|issues| !issues.labels.map { |issue| issue.name}.any?
|issues| !issues.labels.map { |issue| issue.name }.any?
}
filtered_issues.concat(issues_wo_labels)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/github_changelog_generator/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

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 }
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:* ' }

parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator [options]'
Expand Down