gitreport 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,10 +15,10 @@ require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
17
  gem.name = "gitreport"
18
- gem.homepage = "http://github.com/janroesner/gitreport"
18
+ gem.homepage = "https://github.com/gitreport/gitreport-client"
19
19
  gem.license = "MIT"
20
- gem.summary = %Q{gitreport tracks commit and push info of your git projects}
21
- gem.description = %Q{gitreport keeps track of your projects. It collects info about commited and pushed data, submits it to our servers and provides a gorgous frontend to examine, discover and extract the data that you need to generate the payment recipes for your customers. No longer searching or `what did I commit when and where`...}
20
+ gem.summary = %Q{gitreport tracks your commits and pushes metadata to gitreport.com}
21
+ gem.description = %Q{gitreport keeps track of your projects. It collects info about commited and pushed data, submits it to gitreport.com and provides a gorgous frontend to examine, discover and extract the data that you need to generate the payment recipes for your customers, measure your performance, find gaps and get an overview about your work. No longer searching or `what did I commit when and where`...}
22
22
  gem.email = "jan@roesner.it"
23
23
  gem.authors = ["Jan Roesner"]
24
24
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.10
1
+ 0.1.0
data/bin/gitreport CHANGED
@@ -5,25 +5,31 @@ require "rubygems"
5
5
  require 'trollop'
6
6
  require "gitreport"
7
7
 
8
- SUB_COMMANDS = %w(activate deactivate commit sync import)
8
+ SUB_COMMANDS = %w(init activate deactivate commit sync import)
9
+
10
+ def version_info
11
+ File.read(File.dirname(__FILE__)+"/../VERSION").strip
12
+ end
9
13
 
10
14
  def parse_options
11
15
 
12
16
  global_opts = Trollop::options do
17
+ version "gitreport #{version_info} (c) 2011 gitreport.com team"
13
18
  banner <<-EOS
14
19
  gitreport is a commandline tool to synchronize your git repo's with gitreport.com
15
20
 
16
21
  Usage: gitreport <subcommand> [options]
17
22
 
18
- <subcommand> must be one of activate, deactivate, commit, sync, import
23
+ <subcommand> must be one of init, activate, deactivate, commit, sync, import
19
24
 
20
25
  Examples:
21
26
 
22
- gitreport activate - register your project with gitreport.com
27
+ gitreport init - activate automatic data transfer and import existing commit's metadata
28
+ gitreport activate - activate automatic data transfer
23
29
  gitreport deactivate - unregister your project from gitreport.com
24
- gitreport commit - manually transfer your last and stored (offline) commits to gitreport.com
25
- gitreport sync - manually transfer stored (offline) commits to gitreport.com
26
- gitreport import - import all the commits of a project to gitreport.com
30
+ gitreport commit - manually transfer your last and stored (offline) commit's metadata to gitreport.com
31
+ gitreport sync - manually transfer stored (offline) commit's metadata to gitreport.com
32
+ gitreport import - import existing commits metadata
27
33
 
28
34
  gitreport allows the folling [options]:
29
35
  EOS
@@ -40,6 +46,9 @@ gitreport allows the folling [options]:
40
46
 
41
47
  cmd_opts =
42
48
  case cmd
49
+ when "init"
50
+ GitReport::Hook.set!
51
+ GitReport::BatchSender.send! :history
43
52
  when "activate"
44
53
  GitReport::Hook.set!
45
54
  when "deactivate"
data/gitreport.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gitreport"
8
- s.version = "0.0.10"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jan Roesner"]
12
- s.date = "2011-11-07"
13
- s.description = "gitreport keeps track of your projects. It collects info about commited and pushed data, submits it to our servers and provides a gorgous frontend to examine, discover and extract the data that you need to generate the payment recipes for your customers. No longer searching or `what did I commit when and where`..."
12
+ s.date = "2011-11-17"
13
+ s.description = "gitreport keeps track of your projects. It collects info about commited and pushed data, submits it to gitreport.com and provides a gorgous frontend to examine, discover and extract the data that you need to generate the payment recipes for your customers, measure your performance, find gaps and get an overview about your work. No longer searching or `what did I commit when and where`..."
14
14
  s.email = "jan@roesner.it"
15
15
  s.executables = ["gitreport"]
16
16
  s.extra_rdoc_files = [
@@ -74,13 +74,14 @@ Gem::Specification.new do |s|
74
74
  "spec/models/storage_spec.rb",
75
75
  "spec/models/supplier_spec.rb",
76
76
  "spec/spec_helper.rb",
77
- "spec/support/fake_repository.rb"
77
+ "spec/support/fake_repository.rb",
78
+ "templates/gitreport-post-commit.bash"
78
79
  ]
79
- s.homepage = "http://github.com/janroesner/gitreport"
80
+ s.homepage = "https://github.com/gitreport/gitreport-client"
80
81
  s.licenses = ["MIT"]
81
82
  s.require_paths = ["lib"]
82
83
  s.rubygems_version = "1.8.10"
83
- s.summary = "gitreport tracks commit and push info of your git projects"
84
+ s.summary = "gitreport tracks your commits and pushes metadata to gitreport.com"
84
85
 
85
86
  if s.respond_to? :specification_version then
86
87
  s.specification_version = 3
data/lib/hook.rb CHANGED
@@ -5,27 +5,42 @@ module GitReport
5
5
 
6
6
  # creates a hook file if not exists and adds our hook line if it does not exist already
7
7
  def self.set!
8
- create_hook_file! unless hook_file_exists?
9
- set_hook! if hook_file_exists?
8
+ create_hook_file! unless (file_exists? hook_file)
9
+ set_hook!
10
10
  end
11
11
 
12
12
  def self.remove!
13
- remove_hook! if hook_file_exists?
13
+ remove_hook! if (file_exists? hook_file)
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  # creates a git hook file
19
19
  def self.create_hook_file!
20
- write_to_file doc
20
+ write_to_file hook_file, doc
21
+ end
22
+
23
+ # creates the custom hook if it does not exist already
24
+ def self.create_custom_hook!
25
+ write_to_file(custom_hook_file, custom_hook_doc) unless file_exists? custom_hook_file
26
+ end
27
+
28
+ # set's our hook line into an existing hook file if it does not exist already
29
+ # create the custom hook file as well
30
+ def self.set_hook!
31
+ set_line! unless line_exists?
32
+ create_custom_hook!
33
+ puts "Successfully registered post-commit hook."
34
+ rescue
35
+ puts "Error during setting the hook, gitreport will not work as expected!"
21
36
  end
22
37
 
23
38
  # writes given data to hook file
24
- def self.write_to_file data
39
+ def self.write_to_file file, data
25
40
  begin
26
- File.open(hook_file, 'w') {|f| f.write(data);f.chmod(0755);f.close }
41
+ File.open(file, 'w') {|f| f.write(data);f.chmod(0755);f.close }
27
42
  rescue Exception => e
28
- puts "Error while writing hookfile #{hook_file}: #{e}"
43
+ puts "Error while writing hookfile #{file}: #{e}"
29
44
  return false
30
45
  end
31
46
 
@@ -36,25 +51,19 @@ module GitReport
36
51
  def self.file_content
37
52
  begin
38
53
  File.open(hook_file, 'r').read
39
- # @@content ||= File.open(hook_file, 'r').read
40
54
  rescue Exception => e
41
55
  puts "Error while reading hookfile #{hook_file}: #{e}"
42
56
  end
43
57
  end
44
58
 
45
59
  # returns true if a git hook file already exists, false else
46
- def self.hook_file_exists?
47
- File.exists? hook_file
48
- end
49
-
50
- # set's our hook line into an existing hook file if it does not exist already
51
- def self.set_hook!
52
- puts "Successfully registered post-commit hook." if (set_line! unless line_exists?)
60
+ def self.file_exists? file
61
+ File.exists? file
53
62
  end
54
63
 
55
64
  # returns true if the hook file already has a hook line in
56
65
  def self.line_exists?
57
- if file_content.match(/nohup\sbundle\sexec\sgitreport\scommit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&/)
66
+ if file_content.match(/\nnohup\s\.git\/hooks\/gitreport-post-commit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/)
58
67
  return true
59
68
  end
60
69
 
@@ -63,7 +72,7 @@ module GitReport
63
72
 
64
73
  # sets our hook line
65
74
  def self.set_line!
66
- write_to_file(file_content + line)
75
+ write_to_file hook_file, (file_content + line)
67
76
  end
68
77
 
69
78
  # returns the hook files path
@@ -71,51 +80,65 @@ module GitReport
71
80
  @@file ||= GitReport.project.path + "/.git/hooks/post-commit"
72
81
  end
73
82
 
83
+ # returns the custom hook files path
84
+ def self.custom_hook_file
85
+ @@custom_hook_file ||= GitReport.project.path + "/.git/hooks/gitreport-post-commit"
86
+ end
87
+
74
88
  # returns the document header
75
89
  def self.doc
76
90
  "#!/bin/sh\n" +
77
- "# This is a post-commit hook created by gitreport (http://gitreport.com)\n" +
78
- "#\n" +
79
- "# To remove it issue 'bundle exec deactivate' in the projects main directory\n" +
80
- "# In case the gitreport gem is not installed anymore, simply remove this hook file\n" +
81
- "#\n" +
82
- "# Be aware of other post commit hooks that my be mentioned here!\n"
91
+ "# This is a post-commit hook created by gitreport (http://gitreport.com)\n" +
92
+ "#\n" +
93
+ "# To remove it issue 'bundle exec deactivate' in the projects main directory\n" +
94
+ "# In case the gitreport gem is not installed anymore, simply remove this hook file\n" +
95
+ "#\n" +
96
+ "# Be aware of other post commit hooks that my be mentioned here!\n"
83
97
  end
84
98
 
85
99
  # returns the line to activate gitreport via post commit hook
86
100
  def self.line
87
- "\nnohup bundle exec gitreport commit > /dev/null 2> /dev/null < /dev/null &\n"
101
+ "\nnohup .git/hooks/gitreport-post-commit > /dev/null 2> /dev/null < /dev/null &\n"
88
102
  end
89
103
 
90
- # removes the hook
91
- def self.remove_hook!
92
- (remove_hook_file!; return) if hook_file_unchanged?
93
- remove_line! if line_exists?
104
+ # returns the custom hook for gitreport
105
+ def self.custom_hook_doc
106
+ File.read(File.dirname(__FILE__) + "/../templates/gitreport-post-commit.bash")
94
107
  end
95
108
 
96
- # removes the hook file
97
- def self.remove_hook_file!
109
+ # removes the hook
110
+ def self.remove_hook!
98
111
  begin
99
- File.unlink(hook_file)
100
- puts "Successfully removed gitreport post-commit hook (file).\n"
112
+ remove_file!(custom_hook_file) if file_exists? custom_hook_file
113
+ if hook_file_unchanged?
114
+ remove_file! hook_file
115
+ else
116
+ remove_line! if line_exists?
117
+ end
118
+ puts "Successfully removed gitreport post-commit hook files.\n"
101
119
  rescue Exception => e
102
- puts "Error while removing hookfile #{hook_file}: #{e}"
120
+ puts "Error while removing hookfiles: #{e}"
103
121
  end
104
122
  end
105
123
 
124
+ # removes the the given hook file
125
+ def self.remove_file! file
126
+ File.unlink(file)
127
+ end
128
+
106
129
  # returns true if the hook file is ours and was not changed
107
130
  def self.hook_file_unchanged?
108
- Digest::SHA1.hexdigest(file_content) == "e4032a91bb8e07e09ea637c803d8763e26e165e7"
131
+ Digest::SHA1.hexdigest(file_content) == "004c9e7c9124ead7ed347fac7996bd92b6e4e3b9"
109
132
  end
110
133
 
111
134
  # removes our hook line from hook file
112
135
  def self.remove_line!
113
- puts "Successfully removed gitreport post-commit hook.\n" if write_to_file(clean_up(file_content))
136
+ puts "Successfully removed gitreport post-commit hook.\n" if write_to_file(hook_file, (clean_up(file_content)))
114
137
  end
115
138
 
116
139
  # removes our hook line from given content
117
140
  def self.clean_up content
118
- content.gsub(/\nnohup\sbundle\sexec\sgitreport\scommit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/,'')
141
+ content.gsub(/\nnohup\s\.git\/hooks\/gitreport-post-commit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/,'')
119
142
  end
120
143
 
121
144
  end
@@ -18,7 +18,7 @@ describe 'GitReport::Hook' do
18
18
  (File.exists?(hook_file)).should be_true
19
19
  content = File.open(hook_file, 'r').read
20
20
 
21
- content.match(/\nnohup\sbundle\sexec\sgitreport\scommit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/).should be_true
21
+ content.match(/\nnohup\s\.git\/hooks\/gitreport-post-commit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/).should be_true
22
22
  end
23
23
 
24
24
  it 'should insert the gitreport hook into an existing post-commit hook file' do
@@ -30,7 +30,15 @@ describe 'GitReport::Hook' do
30
30
 
31
31
  GitReport::Hook.set!
32
32
  content = File.open(hook_file, 'r').read
33
- content.match(/\nnohup\sbundle\sexec\sgitreport\scommit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/).should be_true
33
+ content.match(/\nnohup\s\.git\/hooks\/gitreport-post-commit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/).should be_true
34
+ end
35
+
36
+ it 'should create the custom hook file' do
37
+ custom_hook_file = "#{GitReport.project.path}/.git/hooks/gitreport-post-commit"
38
+
39
+ GitReport::Hook.set!
40
+
41
+ (File.exists?(custom_hook_file)).should be_true
34
42
  end
35
43
  end
36
44
 
@@ -57,7 +65,18 @@ describe 'GitReport::Hook' do
57
65
  (File.exists?(hook_file)).should be_true
58
66
  content = File.open(hook_file, 'r').read
59
67
  content.should match(/\ssome\spreexisting\shook\sfile\n/)
60
- content.should_not match(/\nnohup\sbundle\sexec\sgitreport\scommit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/)
68
+ content.should_not match(/\nnohup\s\.git\/hooks\/gitreport-post-commit\s>\s\/dev\/null\s2>\s\/dev\/null\s<\s\/dev\/null\s&\n/)
69
+ end
70
+
71
+ it 'should remove the custom hook file' do
72
+ custom_hook_file = "#{GitReport.project.path}/.git/hooks/post-commit"
73
+ File.open(custom_hook_file, 'w+') do |file|
74
+ file.write "# some existing custom hook file\n"
75
+ end
76
+
77
+ GitReport::Hook.remove!
78
+
79
+ (File.exists?(custom_hook_file)).should be_true
61
80
  end
62
81
  end
63
82
  end
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # This is a post-commit hook created by gitreport (http://gitreport.com)
3
+ #
4
+ # To remove it issue 'bundle exec deactivate' in the projects main directory
5
+ # In case the gitreport gem is not installed anymore, simply remove this hook file
6
+ # and remove the calling line from git's 'post-commit' if there is any
7
+
8
+ bundler-installed()
9
+ {
10
+ which bundle > /dev/null 2>&1
11
+ }
12
+
13
+ within-bundled-project(){
14
+ local dir="$(pwd)"
15
+ while [ "$(dirname $dir)" != "/" ]; do
16
+ [ -f "$dir/Gemfile" ] && return
17
+ dir="$(dirname $dir)"
18
+ done
19
+ false
20
+ }
21
+
22
+ run-with-bundler(){
23
+ if bundler-installed && within-bundled-project; then
24
+ bundle exec $@
25
+ else
26
+ $@
27
+ fi
28
+ }
29
+
30
+ run-with-bundler gitreport commit
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.10
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-07 00:00:00.000000000Z
12
+ date: 2011-11-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &70101752506060 !ruby/object:Gem::Requirement
16
+ requirement: &70163877795920 !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: *70101752506060
24
+ version_requirements: *70163877795920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: spork
27
- requirement: &70101752502720 !ruby/object:Gem::Requirement
27
+ requirement: &70163877794280 !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: *70101752502720
35
+ version_requirements: *70163877794280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70101752498940 !ruby/object:Gem::Requirement
38
+ requirement: &70163877790060 !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: *70101752498940
46
+ version_requirements: *70163877790060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webmock
49
- requirement: &70101752495420 !ruby/object:Gem::Requirement
49
+ requirement: &70163877782580 !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: *70101752495420
57
+ version_requirements: *70163877782580
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: shoulda
60
- requirement: &70101752492500 !ruby/object:Gem::Requirement
60
+ requirement: &70163877776460 !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: *70101752492500
68
+ version_requirements: *70163877776460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70101752490200 !ruby/object:Gem::Requirement
71
+ requirement: &70163877767500 !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: *70101752490200
79
+ version_requirements: *70163877767500
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70101752488580 !ruby/object:Gem::Requirement
82
+ requirement: &70163877764560 !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: *70101752488580
90
+ version_requirements: *70163877764560
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70101752486240 !ruby/object:Gem::Requirement
93
+ requirement: &70163877763020 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,11 +98,12 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70101752486240
101
+ version_requirements: *70163877763020
102
102
  description: gitreport keeps track of your projects. It collects info about commited
103
- and pushed data, submits it to our servers and provides a gorgous frontend to examine,
104
- discover and extract the data that you need to generate the payment recipes for
105
- your customers. No longer searching or `what did I commit when and where`...
103
+ and pushed data, submits it to gitreport.com and provides a gorgous frontend to
104
+ examine, discover and extract the data that you need to generate the payment recipes
105
+ for your customers, measure your performance, find gaps and get an overview about
106
+ your work. No longer searching or `what did I commit when and where`...
106
107
  email: jan@roesner.it
107
108
  executables:
108
109
  - gitreport
@@ -168,7 +169,8 @@ files:
168
169
  - spec/models/supplier_spec.rb
169
170
  - spec/spec_helper.rb
170
171
  - spec/support/fake_repository.rb
171
- homepage: http://github.com/janroesner/gitreport
172
+ - templates/gitreport-post-commit.bash
173
+ homepage: https://github.com/gitreport/gitreport-client
172
174
  licenses:
173
175
  - MIT
174
176
  post_install_message:
@@ -183,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
185
  version: '0'
184
186
  segments:
185
187
  - 0
186
- hash: 2055649253981737868
188
+ hash: -1609412549187430430
187
189
  required_rubygems_version: !ruby/object:Gem::Requirement
188
190
  none: false
189
191
  requirements:
@@ -195,5 +197,5 @@ rubyforge_project:
195
197
  rubygems_version: 1.8.10
196
198
  signing_key:
197
199
  specification_version: 3
198
- summary: gitreport tracks commit and push info of your git projects
200
+ summary: gitreport tracks your commits and pushes metadata to gitreport.com
199
201
  test_files: []