From 87f95140d9c494a4c5ee5969ccd722178873ce98 Mon Sep 17 00:00:00 2001 From: Petr Korolev Date: Thu, 5 Mar 2015 16:51:58 +0200 Subject: [PATCH] fix: remote branch parsing --- lib/CHANGELOG.md | 14 ++++++++++++++ lib/github_changelog_generator/parser.rb | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/CHANGELOG.md b/lib/CHANGELOG.md index 59664f1..e4c072b 100644 --- a/lib/CHANGELOG.md +++ b/lib/CHANGELOG.md @@ -1,5 +1,19 @@ # Change Log +## [Unreleased](https://github.com/skywinder/changelog_test/tree/HEAD) + +[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.2...HEAD) + +**Merged pull requests:** + +- 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)) + +## [v0.0.2](https://github.com/skywinder/changelog_test/tree/v0.0.2) (2015-03-04) + +[Full Changelog](https://github.com/skywinder/changelog_test/compare/v0.0.1...v0.0.2) + +## [v0.0.1](https://github.com/skywinder/changelog_test/tree/v0.0.1) (2015-03-02) + \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index fd0723c..c98b9eb 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -26,7 +26,8 @@ module GitHubChangelogGenerator :filter_issues_by_milestone => true, :compare_link => true, :unreleased => true, - :unreleased_label => 'Unreleased' + :unreleased_label => 'Unreleased', + :branch => 'origin' } parser = OptionParser.new { |opts| @@ -129,11 +130,20 @@ module GitHubChangelogGenerator if !options[:user] && !options[:project] remote = `git remote -vv`.split("\n") - match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)?(?:\.git).*/.match(remote[0]) + # try to find repo in format: origin git@github.com:skywinder/Github-Changelog-Generator.git (fetch) + remote.select { |v| v.include? options[:branch] } + match = /.*(?:[:\/])((?:-|\w|\.)*)\/((?:-|\w|\.)*)(?:\.git).*/.match(remote[0]) if match && match[1] && match[2] puts "Detected user:#{match[1]}, project:#{match[2]}" options[:user], options[:project] = match[1], match[2] + else + # try to find repo in format: origin https://github.com/skywinder/ChangelogMerger (fetch) + match = /.*\/((?:-|\w|\.)*)\/((?:-|\w|\.)*).*/.match(remote[0]) + if match && match[1] && match[2] + puts "Detected user:#{match[1]}, project:#{match[2]}" + options[:user], options[:project] = match[1], match[2] + end end end