diggit 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/includes/addons/sources_options.rb +21 -0
- data/includes/analyses/cloc.rb +29 -0
- data/lib/diggit_cli.rb +38 -19
- data/lib/diggit_core.rb +1 -1
- data/spec/diggit_spec.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdc49eaf85ab5ea705046d562d66d05aec279b07
|
4
|
+
data.tar.gz: 8046df957be6fcc9a9296256c9bee91562f8ee7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b42a77ecfb10bc8f95e952d58f1a8bae42395b017038fea82fd5240a2f238645ec9007172dfdc54671e945674bc90bcc96946fadae62238a2781cc9a39c7d52
|
7
|
+
data.tar.gz: f2626d93e3f2e1179d10f16f5cfcb3ddfcb292f99614518925e60349e1c5814bdf721beed37cb6851822ddba08ba6e5595de7a0fd50855f62f5faa3d48cc7247
|
data/README.md
CHANGED
@@ -4,13 +4,13 @@ A ruby tool to analyse Git repositories
|
|
4
4
|
|
5
5
|
# Installation
|
6
6
|
|
7
|
-
|
7
|
+
## From a gem
|
8
8
|
|
9
|
-
|
10
|
-
git clone https://github.com/jrfaller/diggit.git
|
11
|
-
```
|
9
|
+
Just run `gem install diggit`.
|
12
10
|
|
13
|
-
|
11
|
+
## From the source
|
12
|
+
|
13
|
+
Clone diggit using the following command: `git clone https://github.com/jrfaller/diggit.git`. The `dgit` tool is in the `bin` folder.
|
14
14
|
|
15
15
|
# Usage
|
16
16
|
|
@@ -24,7 +24,7 @@ You can add some repositories to be analyzed with the following command: `dgit s
|
|
24
24
|
|
25
25
|
### Using addons
|
26
26
|
|
27
|
-
Addons add features the the diggit tool: for instance capability of writing to a
|
27
|
+
Addons add features the the diggit tool: for instance capability of writing to a MongoDB database, etc. To enable addons for your current diggit folder you can use the following command: `dgit addons add TestAddon`.
|
28
28
|
|
29
29
|
### Setting-up analyses
|
30
30
|
|
@@ -36,10 +36,10 @@ A join is performed after all analyses of all repositories have been performed.
|
|
36
36
|
|
37
37
|
## Running analyses
|
38
38
|
|
39
|
-
Once diggit is configured you can perform the analyses. First you have to
|
39
|
+
Once diggit is configured you can perform the analyses. First, you have to clone the repositories by using `dgit perform clones`. Then you can launch the analyses by using `dgit perform analyses`. Finally, the joins are executed via the command `dgit perform joins`.
|
40
40
|
|
41
41
|
At all time, you can check the status of your diggit folder by using `dgit status`. If you want more info on the status of a given repository, you can use the `dgit sources info https://github.com/jrfaller/diggit.git` command.
|
42
42
|
|
43
43
|
## Cleaning up
|
44
44
|
|
45
|
-
If something is going
|
45
|
+
If something is going wrong, you can always delete the results of the joins by using the command `dgit clean joins` and of the analysis with the command `dgit clean analyses`.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class SourcesOptions < Diggit::Addon
|
4
|
+
|
5
|
+
SOURCES_OPTIONS_FILE = ".dgitsources-options"
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
super
|
9
|
+
@sources_options = {}
|
10
|
+
@sources_options = Oj.load_file(SOURCES_OPTIONS_FILE) if File.exists? SOURCES_OPTIONS_FILE
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
:sources_options
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(meth, *args, &block)
|
18
|
+
@sources_options.send meth, *args, &block
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/includes/analyses/cloc.rb
CHANGED
@@ -20,3 +20,32 @@ class ClocAnalysis < Diggit::Analysis
|
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
|
+
|
24
|
+
|
25
|
+
class ClocPerFileAnalysis < Diggit::Analysis
|
26
|
+
|
27
|
+
def run
|
28
|
+
commit_oid = "HEAD"
|
29
|
+
commit_oid = @addons[:sources_options][@source]["cloc-commit-id"] if @addons.has_key?(:sources_options) && @addons[:sources_options].has_key?(@source) && @addons[:sources_options][@source].has_key?("cloc-commit-id")
|
30
|
+
@repo.checkout(commit_oid, {:strategy=>[:force,:remove_untracked]})
|
31
|
+
cloc = `cloc . --progress-rate=0 --quiet --by-file --yaml --script-lang=Python,python`
|
32
|
+
unless cloc.empty?
|
33
|
+
yaml = YAML.load(cloc.lines[2..-1].join)
|
34
|
+
yaml.delete('header')
|
35
|
+
yaml.delete('SUM')
|
36
|
+
cloc_a = []
|
37
|
+
yaml.each do |key, value|
|
38
|
+
# transform the hash so the filenames are not keys anymore (as they may contain a '.' it is incompatible with mongo)
|
39
|
+
path = key.gsub(/^\.\//, '') # remove the './' at the start of filenames
|
40
|
+
cloc_a << value.merge({:path => path})
|
41
|
+
end
|
42
|
+
output = { source: @source, commit_oid: commit_oid.to_s, cloc: cloc_a }
|
43
|
+
col = @addons[:db].db['cloc-file']
|
44
|
+
col.insert(output)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def clean
|
49
|
+
@addons[:db].db['cloc-file'].remove({source: @source})
|
50
|
+
end
|
51
|
+
end
|
data/lib/diggit_cli.rb
CHANGED
@@ -7,6 +7,11 @@ module Diggit
|
|
7
7
|
|
8
8
|
module Utils
|
9
9
|
|
10
|
+
DONE = '[done]'
|
11
|
+
WARNING = '[warning]'
|
12
|
+
ERROR = '[error]'
|
13
|
+
INFO = '[info]'
|
14
|
+
|
10
15
|
def diggit
|
11
16
|
@diggit = Diggit.new if @diggit.nil?
|
12
17
|
return @diggit
|
@@ -32,22 +37,29 @@ module Diggit
|
|
32
37
|
end
|
33
38
|
|
34
39
|
def status_color(status)
|
35
|
-
if status ==
|
40
|
+
if status == DONE
|
36
41
|
return :green
|
37
42
|
else
|
38
43
|
return :red
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
47
|
+
def say_error(msg)
|
48
|
+
say_status(ERROR, msg, :red)
|
49
|
+
end
|
50
|
+
|
51
|
+
def say_info(msg)
|
52
|
+
say_status(INFO, msg, :blue)
|
53
|
+
end
|
54
|
+
|
55
|
+
def say_done(msg)
|
56
|
+
say_status(DONE, msg, :green)
|
57
|
+
end
|
58
|
+
|
42
59
|
end
|
43
60
|
|
44
61
|
module Cli
|
45
62
|
|
46
|
-
DONE = '[done]'
|
47
|
-
WARNING = '[warning]'
|
48
|
-
ERROR = '[error]'
|
49
|
-
INFO = '[info]'
|
50
|
-
|
51
63
|
class SourcesCli < Thor
|
52
64
|
include Thor::Actions
|
53
65
|
include Utils
|
@@ -70,7 +82,7 @@ module Diggit
|
|
70
82
|
say_status("[#{s[:log][:state]}]", "#{s[:url]}", source_color(s))
|
71
83
|
say_status('[folder]', "#{s[:folder]}", :blue)
|
72
84
|
unless s[:log][:error].empty?
|
73
|
-
|
85
|
+
say_error("#{s[:log][:error][:name]}")
|
74
86
|
say_status('[message]', "#{s[:log][:error][:message]}", :red)
|
75
87
|
say_status('[backtrace]', "", :red)
|
76
88
|
say(s[:log][:error][:backtrace].join("\n"))
|
@@ -108,7 +120,7 @@ module Diggit
|
|
108
120
|
if plugin_ok?(a, Addon)
|
109
121
|
diggit.config.add_addon(a)
|
110
122
|
else
|
111
|
-
|
123
|
+
say_error("error loading addon #{a}")
|
112
124
|
end
|
113
125
|
end
|
114
126
|
end
|
@@ -130,7 +142,7 @@ module Diggit
|
|
130
142
|
if plugin_ok?(j, Join)
|
131
143
|
diggit.config.add_join(j)
|
132
144
|
else
|
133
|
-
|
145
|
+
say_error("error loading join #{j}")
|
134
146
|
end
|
135
147
|
end
|
136
148
|
end
|
@@ -152,7 +164,7 @@ module Diggit
|
|
152
164
|
if plugin_ok?(a, Analysis)
|
153
165
|
diggit.config.add_analysis(a)
|
154
166
|
else
|
155
|
-
|
167
|
+
say_error("error loading analysis #{a}")
|
156
168
|
end
|
157
169
|
end
|
158
170
|
end
|
@@ -175,15 +187,22 @@ module Diggit
|
|
175
187
|
if File.exist?(s[:folder])
|
176
188
|
Rugged::Repository::new(s[:folder])
|
177
189
|
else
|
178
|
-
Rugged::Repository::clone_at(s[:url], s[:folder]
|
190
|
+
Rugged::Repository::clone_at(s[:url], s[:folder], {
|
191
|
+
transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes|
|
192
|
+
msg = "Clone of #{s[:url]} in progress : #{received_objects}/#{total_objects} objects received.\r"
|
193
|
+
$stderr.print msg
|
194
|
+
@last_message_length = msg.length
|
195
|
+
}
|
196
|
+
})
|
197
|
+
print " " * @last_message_length + "\r" # clean the line used to output transfer progress
|
179
198
|
end
|
180
199
|
rescue => e
|
181
200
|
s[:log][:error] = dump_error(e)
|
182
|
-
|
201
|
+
say_error("error cloning #{s[:url]}")
|
183
202
|
else
|
184
203
|
s[:log][:state] = :cloned
|
185
204
|
s[:log][:error] = {}
|
186
|
-
|
205
|
+
say_done("#{s[:url]} cloned")
|
187
206
|
ensure
|
188
207
|
diggit.sources.update(s)
|
189
208
|
end
|
@@ -206,12 +225,12 @@ module Diggit
|
|
206
225
|
rescue => e
|
207
226
|
s[:log][:error] = dump_error(e)
|
208
227
|
s[:log][:analyses] = performed_analyses[1..-2]
|
209
|
-
|
228
|
+
say_error("error performing #{performed_analyses.last} on #{s[:url]}")
|
210
229
|
else
|
211
230
|
s[:log][:analyses] = performed_analyses
|
212
231
|
s[:log][:state] = :finished
|
213
232
|
s[:log][:error] = {}
|
214
|
-
|
233
|
+
say_done("source #{s[:url]} analyzed")
|
215
234
|
ensure
|
216
235
|
FileUtils.cd(diggit.root)
|
217
236
|
diggit.sources.update(s)
|
@@ -224,7 +243,7 @@ module Diggit
|
|
224
243
|
addons = diggit.config.load_addons
|
225
244
|
globs = {}
|
226
245
|
diggit.config.load_joins(diggit.sources.get_all([], {state: :finished, error: false}), addons, globs).each{ |j| j.run }
|
227
|
-
|
246
|
+
say_done("joins performed")
|
228
247
|
end
|
229
248
|
|
230
249
|
end
|
@@ -243,7 +262,7 @@ module Diggit
|
|
243
262
|
s[:log][:analyses] = []
|
244
263
|
s[:log][:error] = {}
|
245
264
|
diggit.sources.update(s)
|
246
|
-
|
265
|
+
say_done("cleaned analyses on #{s[:url]}")
|
247
266
|
end
|
248
267
|
end
|
249
268
|
|
@@ -265,7 +284,7 @@ module Diggit
|
|
265
284
|
cmd = args[2][:current_command].name
|
266
285
|
unless 'init'.eql?(cmd) || 'help'.eql?(cmd)
|
267
286
|
unless File.exist?(DIGGIT_RC)
|
268
|
-
|
287
|
+
say_error("this is not a diggit directory")
|
269
288
|
else
|
270
289
|
diggit
|
271
290
|
end
|
@@ -277,7 +296,7 @@ module Diggit
|
|
277
296
|
FileUtils.touch(DIGGIT_SOURCES)
|
278
297
|
Oj.to_file(DIGGIT_LOG, {})
|
279
298
|
Oj.to_file(DIGGIT_RC, { addons: [], analyses: [], joins: [], options: {} })
|
280
|
-
|
299
|
+
say_done("Diggit folder successfully initialized")
|
281
300
|
end
|
282
301
|
|
283
302
|
desc 'status', "Display the status of the current diggit folder."
|
data/lib/diggit_core.rb
CHANGED
@@ -240,7 +240,7 @@ module Diggit
|
|
240
240
|
if source_defs.nil? || source_defs.empty?
|
241
241
|
sources = hashes
|
242
242
|
else
|
243
|
-
sources = source_defs.map{ |d|
|
243
|
+
sources = source_defs.map{ |d| get(d) }
|
244
244
|
end
|
245
245
|
sources = sources.select{ |s| s[:log][:state] == filter[:state] } if (filter.has_key?(:state))
|
246
246
|
sources = sources.select{ |s| s[:log][:error].empty? != filter[:error] } if (filter.has_key?(:error))
|
data/spec/diggit_spec.rb
CHANGED
@@ -14,7 +14,7 @@ RSpec.describe Diggit::Cli::DiggitCli do
|
|
14
14
|
|
15
15
|
it "should init a diggit folder" do
|
16
16
|
result = capture(:stdout) { Diggit::Cli::DiggitCli.start(["init"]) }
|
17
|
-
expect(result).to include("folder initialized")
|
17
|
+
expect(result).to include("folder successfully initialized")
|
18
18
|
expect(sources).to be_empty
|
19
19
|
expect(log).to be_empty
|
20
20
|
expect(config).to eq({analyses: [], addons: [], joins: [], options: {}})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diggit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Rémy Falleri
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-01-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rugged
|
@@ -67,6 +67,20 @@ dependencies:
|
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.11'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rinruby
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '2.0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.0'
|
70
84
|
- !ruby/object:Gem::Dependency
|
71
85
|
name: rspec
|
72
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,7 @@ files:
|
|
108
122
|
- bin/dgit
|
109
123
|
- includes/addons/db.rb
|
110
124
|
- includes/addons/output.rb
|
125
|
+
- includes/addons/sources_options.rb
|
111
126
|
- includes/addons/test.rb
|
112
127
|
- includes/analyses/authors.rb
|
113
128
|
- includes/analyses/cloc.rb
|
@@ -141,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
156
|
version: '0'
|
142
157
|
requirements: []
|
143
158
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.4.5
|
145
160
|
signing_key:
|
146
161
|
specification_version: 4
|
147
162
|
summary: A Git repository analysis tool.
|