changes_since 0.0.10 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,8 +11,6 @@ From https://github.com/resque/resque
11
11
 
12
12
  `ChangesSince.fetch('v1.25.2')`
13
13
  ```
14
- Unclassified:
15
-
16
14
  * won't be needing rack-test as well (Dan Buch)
17
15
  * Extracted a new WorkerQueueList class out of Rescue::Worker (Einar Jonsson)
18
16
  * implementation of Backend connection with Hash (Ryan Biesemeyer)
@@ -26,7 +24,7 @@ Unclassified:
26
24
  ...
27
25
  ```
28
26
  If you want to use enhanced functionality, you can tag pull requests with #bug, #internal, or #public
29
- The 'Unclassified' would then change to Bug, Internal or Public respectively.
27
+ The 'Unclassified' would then change to Bug, Internal or Public respectively, adding the option :tags => true.
30
28
 
31
29
  There are some additional options you can use
32
30
 
@@ -34,8 +32,6 @@ Author filter:
34
32
 
35
33
  `ChangesSince.fetch('v1.25.2', { :author_filter => ["Dan Buch", "Steve Klabnik"] })`
36
34
  ```
37
- Unclassified:
38
-
39
35
  * won't be needing rack-test as well (Dan Buch)
40
36
  * Fixed typos (Steve Klabnik)
41
37
  * Make sure the filicide is justified (Steve Klabnik)
@@ -62,15 +58,11 @@ Example:
62
58
  ```
63
59
  *Team 1*
64
60
 
65
- Unclassified:
66
-
67
61
  * won't be needing rack-test as well (Dan Buch)
68
62
  * Extracted a new WorkerQueueList class out of Rescue::Worker (Einar Jonsson)
69
63
 
70
64
  *Team 2*
71
65
 
72
- Unclassified:
73
-
74
66
  * update readme.md with hooks link (Ryan Biesemeyer)
75
67
  * speed up test suite (Ryan Biesemeyer)
76
68
  * add info about queue priority to readme (Ryan Biesemeyer)
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'mocha'
25
25
  spec.add_development_dependency 'shoulda'
26
26
  spec.add_dependency "git"
27
+ spec.add_dependency "octokit"
27
28
  end
data/lib/changes_since.rb CHANGED
@@ -1,13 +1,14 @@
1
- require 'git'
2
1
  require 'optparse'
3
- require 'set'
2
+ require 'io/console'
4
3
 
5
4
  module ChangesSince
6
- def self.fetch(tag, teams=nil, repo=nil)
5
+ def self.fetch(teams=nil)
7
6
  options = parse_options
7
+ puts "Enter tag:"
8
+ tag = gets.chomp
8
9
  parser = CommitParser.new(tag, options)
9
10
  commits = parser.parse
10
- printer = ChangelogPrinter.new(commits, teams, options, repo)
11
+ printer = ChangelogPrinter.new(commits, teams, options)
11
12
  printer.print!
12
13
  end
13
14
 
@@ -20,10 +21,6 @@ module ChangesSince
20
21
  options[:all] = a
21
22
  end
22
23
 
23
- opts.on("-s", "--sha", "Include commit sha in the output") do |s|
24
- options[:sha] = s
25
- end
26
-
27
24
  opts.on("-f", "--filter [authors]", "Limit to authors matching the passed string(s). Comma-separated list works.") do |authors|
28
25
  options[:author_filter] = authors.split(",")
29
26
  end
@@ -32,13 +29,10 @@ module ChangesSince
32
29
  options[:tags] = t
33
30
  end
34
31
 
35
- opts.on("-r", "--risk", "Group commits by high, medium or low risk") do |r|
36
- options[:risk] = r
37
- end
38
-
39
32
  opts.on("-m", "--markdown", "Use tables in Atlassian as markdown") do |m|
40
33
  options[:markdown] = m
41
34
  end
35
+
42
36
  end.parse!
43
37
  options
44
38
  end
@@ -46,3 +40,4 @@ end
46
40
 
47
41
  require 'changes_since/commit_parser'
48
42
  require 'changes_since/changelog_printer'
43
+ require 'changes_since/api_client'
@@ -0,0 +1,69 @@
1
+ require 'git'
2
+ require 'octokit'
3
+
4
+ module ChangesSince
5
+ class ApiClient
6
+
7
+ attr_reader :access_token, :client, :repo
8
+
9
+ def initialize
10
+ puts "Please enter your Github credentials:"
11
+ print "Username:"
12
+ username = gets.chomp
13
+ print "Password:"
14
+ password = STDIN.noecho(&:gets).chomp
15
+ puts
16
+
17
+ @client = Octokit::Client.new(
18
+ :login => username,
19
+ :password => password
20
+ )
21
+
22
+ begin
23
+ fetch_authorization
24
+ rescue Octokit::OneTimePasswordRequired => e
25
+ puts "Enter two factor auth token:"
26
+ otp_token = gets.chomp
27
+ fetch_authorization(otp_token)
28
+ end
29
+
30
+ @client = Octokit::Client.new(:access_token => access_token)
31
+ git = Git.open(Dir.pwd)
32
+ @repo = git.remote.url.split(/[:.]/)[-2]
33
+ end
34
+
35
+ def fetch_authorization(otp_token=nil)
36
+ options = { :scopes => ["repo"], :note => "Changes Since" }
37
+
38
+ headers = {}
39
+ if otp_token
40
+ headers = { "X-GitHub-OTP" => otp_token }
41
+ options.merge!(:headers => headers)
42
+ end
43
+
44
+ begin
45
+ @access_token = client.create_authorization(options)
46
+ rescue Octokit::UnprocessableEntity => e
47
+ authorizations = client.authorizations(:headers => headers)
48
+ @access_token = authorizations.find { |a| a.note == "Changes Since" }.token
49
+ end
50
+ end
51
+
52
+ def pull_request_risks(number)
53
+ pr = client.pull_request(repo, number)
54
+ body = pr.body
55
+ if pr.body.include?("Risks")
56
+ body = body[pr.body.index("Risks") + 5, body.size]
57
+ elsif pr.body.include?("Risk")
58
+ body = body[pr.body.index("Risk") + 4, body.size]
59
+ else
60
+ return " "
61
+ end
62
+ body = body.strip
63
+ if index = body.index(/\r\n\r\n/)
64
+ body = body[0, index]
65
+ end
66
+ body
67
+ end
68
+ end
69
+ end
@@ -1,6 +1,6 @@
1
1
  module ChangesSince
2
2
  class ChangelogPrinter
3
- attr_reader :teams, :options, :repo
3
+ attr_reader :teams, :options, :repo, :api_client
4
4
 
5
5
  TAGS = {
6
6
  :public => 'Public',
@@ -8,11 +8,15 @@ module ChangesSince
8
8
  :internal => 'Internal'
9
9
  }
10
10
 
11
- def initialize(commits, teams, options, repo)
11
+ def initialize(commits, teams, options)
12
12
  @commits = commits
13
13
  @teams = teams
14
14
  @options = options
15
- @repo = repo
15
+ git = Git.open(Dir.pwd)
16
+ @repo = "https://github.com/" << git.remote.url.split(/[:.]/)[-2]
17
+ if options[:markdown]
18
+ @api_client = ApiClient.new
19
+ end
16
20
  end
17
21
 
18
22
  def print!
@@ -29,7 +33,7 @@ module ChangesSince
29
33
  author_re = /#{members.join("|")}/i
30
34
  team_commits = @commits.select do |commit|
31
35
  [commit.author.name, commit.author.email].any? do |str|
32
- str =~ author_re
36
+ str.force_encoding(Encoding::UTF_8) =~ author_re
33
37
  end
34
38
  end
35
39
  next if team_commits.empty?
@@ -45,9 +49,7 @@ module ChangesSince
45
49
 
46
50
  def print_team_name(name)
47
51
  if options[:markdown]
48
- row = "||*#{name}*||Author||PR||"
49
- row << "Commit||" if options[:sha]
50
- row << "Risk||" if options[:risk]
52
+ row = "||*#{name}*||Author||PR||Risk||"
51
53
  puts row
52
54
  else
53
55
  puts "\n*#{name}*\n"
@@ -80,7 +82,6 @@ module ChangesSince
80
82
  pr = message_lines.first.split(" from ").first.split("#").last
81
83
  else
82
84
  title = message_lines.first
83
- sha = options[:sha] ? commit.sha[0..9] : ''
84
85
  end
85
86
  title.gsub!("##{tag}", "") if tag
86
87
  branch_author = commit.author.name
@@ -88,8 +89,7 @@ module ChangesSince
88
89
  text = "|#{title}|"
89
90
  text << "#{branch_author}|"
90
91
  text << "[##{pr}|#{@repo}/pull/#{pr}]|" if @repo && pr
91
- text << "[#{sha}|#{@repo}/commit/#{sha}]|" if sha
92
- text << " |" if options[:risk]
92
+ text << "#{api_client.pull_request_risks(pr)}|"
93
93
  else
94
94
  text = "* #{title} (#{branch_author})"
95
95
  end
@@ -1,3 +1,5 @@
1
+ require 'git'
2
+
1
3
  module ChangesSince
2
4
  class CommitParser
3
5
  attr_reader :log, :options
@@ -1,3 +1,3 @@
1
1
  module ChangesSince
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -160,16 +160,9 @@ class ChangelogPrinterTest < Test::Unit::TestCase
160
160
  printer.print_message(commit)
161
161
  end
162
162
 
163
- should "print out the title, branch author PR and sha" do
164
- printer = ChangesSince::ChangelogPrinter.new(stub, stub, { :markdown => true, :sha => true }, "repo")
165
- commit = stub(:author => stub(:name => "NAME"), :message => "MESSAGE", :sha => "123")
166
- printer.expects(:puts).with('|MESSAGE|NAME|[123|repo/commit/123]|')
167
- printer.print_message(commit)
168
- end
169
-
170
163
  should "allow a column for risk" do
171
164
  printer = ChangesSince::ChangelogPrinter.new(stub, stub, { :markdown => true, :risk => true }, "repo")
172
- commit = stub(:author => stub(:name => "NAME"), :message => "MESSAGE", :sha => "123")
165
+ commit = stub(:author => stub(:name => "NAME"), :message => "MESSAGE")
173
166
  printer.expects(:puts).with('|MESSAGE|NAME|[|repo/commit/]| |')
174
167
  printer.print_message(commit)
175
168
  end
metadata CHANGED
@@ -1,107 +1,134 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: changes_since
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Ashwin Hegde
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2014-07-17 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
14
22
  name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.5'
20
- type: :development
21
23
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
24
27
  - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.5'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 10.1.1
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 1
32
+ - 5
33
+ version: "1.5"
34
34
  type: :development
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
35
38
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - "="
43
+ - !ruby/object:Gem::Version
44
+ hash: 73
45
+ segments:
46
+ - 10
47
+ - 1
48
+ - 1
40
49
  version: 10.1.1
41
- - !ruby/object:Gem::Dependency
42
- name: test-unit
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
50
  type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: test-unit
49
54
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: mocha
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
62
64
  type: :development
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ name: mocha
63
68
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: shoulda
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
76
78
  type: :development
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: shoulda
77
82
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ hash: 3
89
+ segments:
90
+ - 0
91
+ version: "0"
92
+ type: :development
93
+ version_requirements: *id005
94
+ - !ruby/object:Gem::Dependency
84
95
  name: git
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
96
+ prerelease: false
97
+ requirement: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
90
106
  type: :runtime
107
+ version_requirements: *id006
108
+ - !ruby/object:Gem::Dependency
109
+ name: octokit
91
110
  prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '>='
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- description: Shows you all the merged pull requests since a certain git tag in a nice
98
- format
99
- email:
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ type: :runtime
121
+ version_requirements: *id007
122
+ description: Shows you all the merged pull requests since a certain git tag in a nice format
123
+ email:
100
124
  - ahegde@zendesk.com
101
125
  executables: []
126
+
102
127
  extensions: []
128
+
103
129
  extra_rdoc_files: []
104
- files:
130
+
131
+ files:
105
132
  - .gitignore
106
133
  - .travis.yml
107
134
  - Gemfile
@@ -110,37 +137,48 @@ files:
110
137
  - Rakefile
111
138
  - changes_since.gemspec
112
139
  - lib/changes_since.rb
140
+ - lib/changes_since/api_client.rb
113
141
  - lib/changes_since/changelog_printer.rb
114
142
  - lib/changes_since/commit_parser.rb
115
143
  - lib/changes_since/version.rb
116
144
  - test/changes_since/changelog_printer_test.rb
117
145
  - test/changes_since_test.rb
118
146
  - test/helper.rb
147
+ has_rdoc: true
119
148
  homepage: http://rubygems.org/gems/changes_since
120
- licenses:
149
+ licenses:
121
150
  - MIT
122
- metadata: {}
123
151
  post_install_message:
124
152
  rdoc_options: []
125
- require_paths:
153
+
154
+ require_paths:
126
155
  - lib
127
- required_ruby_version: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - '>='
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- required_rubygems_version: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - '>='
135
- - !ruby/object:Gem::Version
136
- version: '0'
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 0
173
+ version: "0"
137
174
  requirements: []
175
+
138
176
  rubyforge_project:
139
- rubygems_version: 2.0.14
177
+ rubygems_version: 1.6.2
140
178
  signing_key:
141
- specification_version: 4
179
+ specification_version: 3
142
180
  summary: Git Changes since a tag
143
- test_files:
181
+ test_files:
144
182
  - test/changes_since/changelog_printer_test.rb
145
183
  - test/changes_since_test.rb
146
184
  - test/helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 7f54efccb749c5d03ec76172fcbb188f3b343dd1
4
- data.tar.gz: 9175935cca08e5e61cfc6ce0bc885a2b257b3626
5
- SHA512:
6
- metadata.gz: 6726da3ef54fba175e143243a70e7b7092d9dd4768203b0d3a1497e69ee1f9f698169fcbab6118f143bcb78884ffd0174988c0d0d860df990cc1c44ee3189ff9
7
- data.tar.gz: 23bfce2003de71382f2f400df579a923e1c3cfcc7ac1d646db0c58eeea0f65dd2f59c78b7e673edfae962826c47b08a6767361b1c5f3e1f12f488c73acfcd1aa