gitreport 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/gitreport +3 -0
- data/gitreport.gemspec +1 -1
- data/lib/batch_sender.rb +24 -3
- data/lib/gitreport.rb +10 -0
- data/lib/sender.rb +31 -5
- data/spec/models/batch_sender_spec.rb +7 -0
- data/spec/support/fake_repository.rb +25 -0
- metadata +18 -18
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/bin/gitreport
CHANGED
@@ -29,12 +29,15 @@ gitreport allows the folling [options]:
|
|
29
29
|
EOS
|
30
30
|
|
31
31
|
opt :dry_run, "Don't actually do anything", :short => "-n"
|
32
|
+
opt :trace, "Print out stack trace in case of an error", :short => "-t"
|
32
33
|
stop_on SUB_COMMANDS
|
33
34
|
end
|
34
35
|
|
35
36
|
cmd = ARGV.shift
|
36
37
|
Trollop::die "You must specify at least one command" unless cmd
|
37
38
|
|
39
|
+
GitReport.global_opts = global_opts
|
40
|
+
|
38
41
|
cmd_opts =
|
39
42
|
case cmd
|
40
43
|
when "activate"
|
data/gitreport.gemspec
CHANGED
data/lib/batch_sender.rb
CHANGED
@@ -43,11 +43,32 @@ module GitReport
|
|
43
43
|
request.body = body(batch)
|
44
44
|
http.open_timeout = configuration.timeout
|
45
45
|
http.read_timeout = configuration.timeout
|
46
|
-
http.request request
|
46
|
+
http.request request unless GitReport.global_opts[:dry_run]
|
47
47
|
end
|
48
|
-
raise
|
48
|
+
raise GitReport::ServerError unless (response.code == "200" or response.code == "401") unless GitReport.global_opts[:dry_run]
|
49
49
|
rescue Exception => e
|
50
|
-
|
50
|
+
if e.is_a?(GitReport::ServerError)
|
51
|
+
puts "A server error occured during data transfer."
|
52
|
+
if GitReport.global_opts[:trace]
|
53
|
+
puts "Exception: #{e}\n"
|
54
|
+
puts "Message: #{JSON.parse(response.body)["message"]}\n"
|
55
|
+
else
|
56
|
+
puts "Run with --trace to get more info."
|
57
|
+
end
|
58
|
+
exit
|
59
|
+
else
|
60
|
+
puts "A client error occured during data transfer."
|
61
|
+
if GitReport.global_opts[:trace]
|
62
|
+
puts "Exception: #{e}\n"
|
63
|
+
e.backtrace.each do |line|
|
64
|
+
puts "#{line}\n"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
puts "Run with --trace to get more info."
|
68
|
+
end
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
51
72
|
return false
|
52
73
|
end
|
53
74
|
|
data/lib/gitreport.rb
CHANGED
@@ -18,6 +18,8 @@ require 'supplier'
|
|
18
18
|
|
19
19
|
module GitReport
|
20
20
|
|
21
|
+
class ServerError < StandardError;end
|
22
|
+
|
21
23
|
# mattr_reader
|
22
24
|
def self.project
|
23
25
|
@@project ||= GitReport::Project.new
|
@@ -27,4 +29,12 @@ module GitReport
|
|
27
29
|
@@config ||= GitReport::Configuration.new
|
28
30
|
end
|
29
31
|
|
32
|
+
def self.global_opts= options={}
|
33
|
+
@@global_opts = options
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.global_opts
|
37
|
+
@@global_opts || {}
|
38
|
+
end
|
39
|
+
|
30
40
|
end
|
data/lib/sender.rb
CHANGED
@@ -4,9 +4,23 @@ module GitReport
|
|
4
4
|
|
5
5
|
# sends or saves the commits
|
6
6
|
def self.send! options = nil
|
7
|
-
|
7
|
+
begin
|
8
|
+
commits = GitReport::Supplier.commits(options)
|
9
|
+
rescue Exception => e
|
10
|
+
puts "A client error occured during data transfer."
|
11
|
+
if GitReport.global_opts[:trace]
|
12
|
+
puts "Exception: #{e}\n"
|
13
|
+
e.backtrace.each do |line|
|
14
|
+
puts "#{line}\n"
|
15
|
+
end
|
16
|
+
else
|
17
|
+
puts "Run with --trace to get more info."
|
18
|
+
end
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
8
22
|
commits.each do |commit|
|
9
|
-
send_data!(commit) ? commits = commits.inject([]){ |a,i| ( a << i unless i == commit );a } : break
|
23
|
+
send_data!(commit) ? commits = commits.inject([]){ |a,i| ( a << i unless i == commit );a } : break
|
10
24
|
end
|
11
25
|
storage.save! commits
|
12
26
|
|
@@ -24,11 +38,23 @@ module GitReport
|
|
24
38
|
request.body = commit.to_json
|
25
39
|
http.open_timeout = configuration.timeout
|
26
40
|
http.read_timeout = configuration.timeout
|
27
|
-
http.request request
|
41
|
+
http.request request unless GitReport.global_opts[:dry_run]
|
28
42
|
end
|
29
|
-
raise
|
43
|
+
raise GitReport::ServerError unless (response.code == "201" or response.code == "401") unless GitReport.global_opts[:dry_run]
|
30
44
|
rescue Exception => e
|
31
|
-
|
45
|
+
if e.is_a?(GitReport::ServerError)
|
46
|
+
puts "A server error occured during data transfer."
|
47
|
+
if GitReport.global_opts[:trace]
|
48
|
+
puts "Exception: #{e}\n"
|
49
|
+
puts "Message: #{JSON.parse(response.body)["message"]}\n"
|
50
|
+
else
|
51
|
+
puts "Run with --trace to get more info."
|
52
|
+
end
|
53
|
+
else
|
54
|
+
puts "A client error occured during data transfer."
|
55
|
+
puts "Exception: #{e}\n"
|
56
|
+
end
|
57
|
+
|
32
58
|
return false
|
33
59
|
end
|
34
60
|
|
@@ -28,6 +28,13 @@ describe 'GitReport::BatchSender' do
|
|
28
28
|
data["project"].size.should == 7
|
29
29
|
data["project"]["project_name"].should == GitReport.project.name
|
30
30
|
end
|
31
|
+
|
32
|
+
it 'should not raise an error in case of the word commit at the start of a commit message' do
|
33
|
+
@repo.create_error_commit1
|
34
|
+
|
35
|
+
lambda{ body = GitReport::BatchSender.body(GitReport::BatchSender.batches(:history).first) }.should_not raise_error
|
36
|
+
end
|
37
|
+
|
31
38
|
end
|
32
39
|
|
33
40
|
describe '#batches' do
|
@@ -55,6 +55,31 @@ class FakeRepository
|
|
55
55
|
return @project_dir
|
56
56
|
end
|
57
57
|
|
58
|
+
def create_error_commit1
|
59
|
+
@project_dir = Dir.new(File.dirname(Tempfile.new('fake').path)).path + "/project"
|
60
|
+
FileUtils.rm_rf Dir.glob(@project_dir)
|
61
|
+
FileUtils.rmdir @project_dir if File.exists?(@project_dir)
|
62
|
+
Dir.mkdir(@project_dir) unless File.exists?(@project_dir)
|
63
|
+
|
64
|
+
# create a project
|
65
|
+
project = Git.init(@project_dir)
|
66
|
+
|
67
|
+
# add a first commit
|
68
|
+
File.open("#{@project_dir}/file1", 'w+') do |file|
|
69
|
+
file.write "file content 1"
|
70
|
+
end
|
71
|
+
|
72
|
+
project.add('file1')
|
73
|
+
project.commit('commit with file1')
|
74
|
+
|
75
|
+
File.open("#{@project_dir}/file2", 'w+') do |file|
|
76
|
+
file.write "This commit will cause an error in the git library"
|
77
|
+
end
|
78
|
+
|
79
|
+
project.add('file2')
|
80
|
+
project.commit("Resque to the rescue\n\ncommit batches are processed async now.")
|
81
|
+
end
|
82
|
+
|
58
83
|
def create_project_config_file
|
59
84
|
File.open("#{@project_dir}/.gitreport", 'w+') do |file|
|
60
85
|
file.write "---\n"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitreport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-17 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &70199993266920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70199993266920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: spork
|
27
|
-
requirement: &
|
27
|
+
requirement: &70199993266440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>'
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.0.rc
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70199993266440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70199993265960 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70199993265960
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &70199993282620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70199993282620
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: shoulda
|
60
|
-
requirement: &
|
60
|
+
requirement: &70199993282140 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70199993282140
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
|
-
requirement: &
|
71
|
+
requirement: &70199993281660 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 1.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70199993281660
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: jeweler
|
82
|
-
requirement: &
|
82
|
+
requirement: &70199993281180 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.6.4
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70199993281180
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rcov
|
93
|
-
requirement: &
|
93
|
+
requirement: &70199993280700 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70199993280700
|
102
102
|
description: gitreport keeps track of your projects. It collects info about commited
|
103
103
|
and pushed data, submits it to our servers and provides a gorgous frontend to examine,
|
104
104
|
discover and extract the data that you need to generate the payment recipes for
|
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
181
|
version: '0'
|
182
182
|
segments:
|
183
183
|
- 0
|
184
|
-
hash:
|
184
|
+
hash: 545720071683109079
|
185
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
186
|
none: false
|
187
187
|
requirements:
|