github_changes 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91e338d415d8597cc4d26affc9f90edee506b5a8
4
- data.tar.gz: f161536c7da8b87c25d208ed3f313b7bf6100f35
3
+ metadata.gz: 271f7ac2411a473f933f57f6abd6e15bc7a1915a
4
+ data.tar.gz: 8c9d02ba79d7903207688464906477dcb7c9e193
5
5
  SHA512:
6
- metadata.gz: 12ad2188c031f14f1b028d12d02702d0adee8c714d4646240d9bc539ef7eeb89394adff81bfbf7f350d43d8515b5713a61a6e504c4640168501f8ae4f46176e2
7
- data.tar.gz: 218d4597fde0c6c4d62ac0c351ff69f188593f9985cce98dc732ddabd9fd96ae5bfc4744fff13fdecd32ee902d60fb6755811cd0221ed107a36aa70f987121bb
6
+ metadata.gz: 3e13751f86e772d8dc7c7a3dc072cea73817f68445d2b4cf4515da0f6175c88281b2f2546de920f179c0afcba528a3a1bad782224baa31df5ef93174d41c73d0
7
+ data.tar.gz: 587767b2d9f9be65232b0ba416706ab0196b40f2b6a55540e236b8f2bb890c61a7188d6e9a7989d78be1363eafe55725f51a06fff58475bae788c35287aad461
@@ -3,6 +3,10 @@ $thor_runner = false
3
3
 
4
4
  module ChangelogGenerator
5
5
  class CLI < Thor
6
+ def self.exit_on_failure?
7
+ true
8
+ end
9
+
6
10
  desc "hello NAME", "This will greet you"
7
11
  long_desc <<-EOS
8
12
  `hello NAME` will print out a message to the person of your choosing.
@@ -26,12 +30,15 @@ module ChangelogGenerator
26
30
  method_option :label_filter, :aliases => "-l", :type => :string
27
31
  def generate()
28
32
  generator = Generator.new(options[:user], options[:repo], options[:from_ref], options[:to_ref], options[:label_filter])
29
- puts generator.description
30
33
  begin
31
- puts generator.changelog
34
+ output = generator.description + "\n\n"
35
+ output << generator.changelog
36
+ puts output
32
37
  rescue Exception => e
38
+ puts e.message
33
39
  STDERR.puts "#{e}"
34
40
  STDERR.puts e.backtrace
41
+ throw e
35
42
  end
36
43
  end
37
44
  end
@@ -20,9 +20,9 @@ module ChangelogGenerator
20
20
  end
21
21
 
22
22
  def description
23
- description = "Changes for #{user}/#{repo_name} from #{from_ref} to #{to_ref}"
23
+ description = "Changes for `#{user}/#{repo_name}` from `#{from_ref}` to `#{to_ref}`"
24
24
  if label_filter
25
- description << " with label '#{label_filter}'"
25
+ description << " with label `#{label_filter}`"
26
26
  end
27
27
  description
28
28
  end
@@ -37,13 +37,13 @@ module ChangelogGenerator
37
37
  start_date, end_date = *date_range_for_references(start_ref, end_ref)
38
38
  # puts "Start: #{start_ref}, End: #{end_ref}"
39
39
  unless start_date && end_date
40
- return "Failed to acquire date range from references"
40
+ abort "Failed to acquire date range from references"
41
41
  end
42
42
  pulls = pull_requests_for_date_range(start_date, end_date)
43
43
  pull_nums = pulls.map { |p| p['number'] }
44
44
 
45
45
  if pull_nums.empty?
46
- return "No PRs found matching criteria"
46
+ abort "No PRs found matching criteria"
47
47
  else
48
48
  # puts " PRs: #{pull_nums}"
49
49
  # puts
@@ -61,7 +61,7 @@ module ChangelogGenerator
61
61
  end
62
62
 
63
63
  if pull_nums.empty?
64
- return "No PRs found matching criteria"
64
+ abort "No PRs found matching criteria"
65
65
  end
66
66
 
67
67
  pulls = pull_nums.map { |p| github.pull_requests.get(user, repo, p) }
@@ -83,20 +83,17 @@ module ChangelogGenerator
83
83
  logs = pulls.map { |p| p.changelog_text }
84
84
  logs = logs.reject(&:empty?)
85
85
 
86
- string = "```\n"
87
- string << logs.join("\n")
88
- string << "\n```"
89
- string << "\n\n"
86
+ string = logs.join("\n") << "\n\n"
90
87
 
91
- # string << "<https://github.com/#{user}/#{repo}/pulls?q=is%3Apr+#{commits.join("+")}|PRs> | "
92
- # string << "<https://github.com/#{user}/#{repo}/issues?q=is%3Aissue+#{connected_issue_nums.join("+")}|Issues> | "
93
- # string << "<https://github.com/#{user}/#{repo}/issues?q=#{commits.join("+")}+#{connected_issue_nums.join("+")}|Both>"
88
+ show_prs = commits.count <= 20
89
+ show_issues = show_prs && (connected_issue_nums.count > 0)
90
+ show_both = show_prs && show_issues && (commits.count + connected_issue_nums.count <= 20)
94
91
 
95
- string << "PRs: https://github.com/#{user}/#{repo}/pulls?q=is%3Apr+#{commits.join("+")}\n"
96
- string << "Issues: https://github.com/#{user}/#{repo}/issues?q=is%3Aissue+#{connected_issue_nums.join("+")}\n"
97
- string << "Both: https://github.com/#{user}/#{repo}/issues?q=#{commits.join("+")}+#{connected_issue_nums.join("+")}\n"
92
+ string << "<https://github.com/#{user}/#{repo}/pulls?q=is%3Apr+#{commits.join("+")}|PRs>" if show_prs
93
+ string << " | <https://github.com/#{user}/#{repo}/issues?q=is%3Aissue+#{connected_issue_nums.join("+")}|Issues>" if show_issues
94
+ string << " | <https://github.com/#{user}/#{repo}/issues?q=#{commits.join("+")}+#{connected_issue_nums.join("+")}|Both>" if show_both
98
95
 
99
- string << "\n"
96
+ string
100
97
  end
101
98
 
102
99
  def github
@@ -1,3 +1,3 @@
1
1
  module ChangelogGenerator
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github_changes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Rayment
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-02 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor