diggit 2.0.2 → 2.1.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/bin/dgit +18 -12
- data/lib/dgit.rb +1 -0
- data/lib/dgit/core.rb +68 -146
- data/lib/dgit/entries.rb +159 -0
- data/lib/dgit/version.rb +1 -1
- data/plugins/analysis/cloc.rb +0 -1
- data/plugins/analysis/javadoc.rb +43 -0
- data/plugins/analysis/tex.rb +0 -1
- data/spec/core_spec.rb +50 -12
- data/spec/dgit/plugins/analysis/test_analysis_with_clean_error.rb +27 -0
- data/spec/dgit/plugins/analysis/test_analysis_with_sources_options.rb +1 -1
- data/spec/dgit/plugins/join/test_join_with_clean_error.rb +29 -0
- data/spec/dgit/plugins/join/test_join_with_error.rb +29 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fa14be04009f4668ce08541bcc05aa050308de7
|
4
|
+
data.tar.gz: 2f956728d1a7d6e2ea999a0d2aa59d60ecbad58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53da80f0affd555bb133b5b36129772d1a915fb5d04661f1d5b7a7c94d00a1cf347d092d5775f05372bd7b434ee28a21e6b3c0822d4a84485e4d94c4e2c20d7c
|
7
|
+
data.tar.gz: 44488dca2f0ad7d39b788012e73c1ee17c608d958bde77be62cdb1cd6d20c5f84f11a6ac022e0e8663d0ad054a63f6bd89ce730e0a8d16d760ef477adbb82d90
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog of Diggit
|
2
2
|
|
3
|
+
### Version 2.1.0
|
4
|
+
* Now repositories are reseted to master by default
|
5
|
+
* Journal infrastructure has been vastly improved
|
6
|
+
* Journal now records time for analyses and joins
|
7
|
+
* Journal now handles runnables with clean errors
|
8
|
+
|
3
9
|
### Version 2.0.2
|
4
10
|
* Fixed analysis cleaning
|
5
11
|
* Fixed error in gemspec
|
data/bin/dgit
CHANGED
@@ -75,7 +75,7 @@ module Diggit
|
|
75
75
|
sources = Diggit::Dig.it.journal.sources
|
76
76
|
sources.each_index do |idx|
|
77
77
|
msg = "#{idx} #{sources[idx].url} (#{sources[idx].state})"
|
78
|
-
sources[idx].error? ? Log.error(msg) : Log.ok(msg)
|
78
|
+
sources[idx].entry.error? ? Log.error(msg) : Log.ok(msg)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -98,8 +98,8 @@ module Diggit
|
|
98
98
|
errors.action do |_global_options, _options, _args|
|
99
99
|
sources = Diggit::Dig.it.journal.sources
|
100
100
|
sources.each_index do |idx|
|
101
|
-
msg = "#{idx} #{sources[idx].url} (#{sources[idx].state})"
|
102
|
-
Log.error msg if sources[idx].error?
|
101
|
+
msg = "#{idx} #{sources[idx].url} (#{sources[idx].entry.state})"
|
102
|
+
Log.error msg if sources[idx].entry.error?
|
103
103
|
end
|
104
104
|
end
|
105
105
|
end
|
@@ -108,16 +108,22 @@ module Diggit
|
|
108
108
|
c.command :info do |info|
|
109
109
|
info.action do |_global_options, _options, args|
|
110
110
|
src = Diggit::Dig.it.journal.sources_by_ids(args[0].to_i)[0]
|
111
|
-
|
112
|
-
|
113
|
-
Log.info "
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
Log.info "URL: #{src.url}"
|
112
|
+
Log.info "State: #{src.entry.state}"
|
113
|
+
Log.info "Performed analyses:" unless src.entry.performed.empty?
|
114
|
+
src.entry.performed.each do |e|
|
115
|
+
Log.indent do
|
116
|
+
Log.info "#{e.name}, time: #{e.duration}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
Log.info "Canceled analyses:" unless src.entry.canceled.empty?
|
120
|
+
src.entry.canceled.each do |e|
|
118
121
|
Log.indent do
|
119
|
-
Log.
|
120
|
-
Log.
|
122
|
+
Log.info "#{e.name}, time: #{e.duration}"
|
123
|
+
Log.indent do
|
124
|
+
Log.error e.error.message
|
125
|
+
Log.error e.error.backtrace.join("\n")
|
126
|
+
end
|
121
127
|
end
|
122
128
|
end
|
123
129
|
end
|
data/lib/dgit.rb
CHANGED
data/lib/dgit/core.rb
CHANGED
@@ -22,6 +22,7 @@ require 'oj'
|
|
22
22
|
require 'rugged'
|
23
23
|
require 'singleton'
|
24
24
|
require_relative 'log'
|
25
|
+
require_relative 'entries'
|
25
26
|
|
26
27
|
class String
|
27
28
|
# Returns a underscore cased version of the string.
|
@@ -56,12 +57,11 @@ end
|
|
56
57
|
|
57
58
|
module Diggit
|
58
59
|
class Source
|
59
|
-
attr_reader :url, :repository
|
60
|
-
attr_accessor :entry
|
60
|
+
attr_reader :url, :repository, :entry
|
61
61
|
|
62
62
|
def initialize(url)
|
63
63
|
@url = url
|
64
|
-
@entry =
|
64
|
+
@entry = SourceEntry.new
|
65
65
|
@repository = nil
|
66
66
|
end
|
67
67
|
|
@@ -73,81 +73,32 @@ module Diggit
|
|
73
73
|
Dig.it.file_path("sources/#{id}")
|
74
74
|
end
|
75
75
|
|
76
|
-
def error?
|
77
|
-
!(@entry[:last_error].nil? || @entry[:last_error].empty?)
|
78
|
-
end
|
79
|
-
|
80
|
-
def error
|
81
|
-
@entry[:last_error]
|
82
|
-
end
|
83
|
-
|
84
|
-
def error=(error)
|
85
|
-
@entry[:last_error] = error
|
86
|
-
end
|
87
|
-
|
88
|
-
def state
|
89
|
-
@entry[:state]
|
90
|
-
end
|
91
|
-
|
92
|
-
def state=(state)
|
93
|
-
@entry[:state] = state
|
94
|
-
end
|
95
|
-
|
96
|
-
def new?
|
97
|
-
@entry[:state] == :new
|
98
|
-
end
|
99
|
-
|
100
|
-
def cloned?
|
101
|
-
@entry[:state] == :cloned
|
102
|
-
end
|
103
|
-
|
104
|
-
def all_analyses
|
105
|
-
performed_analyses + ongoing_analyses
|
106
|
-
end
|
107
|
-
|
108
|
-
def performed_analyses
|
109
|
-
@entry[:performed_analyses]
|
110
|
-
end
|
111
|
-
|
112
|
-
def ongoing_analyses
|
113
|
-
@entry[:ongoing_analyses]
|
114
|
-
end
|
115
|
-
|
116
|
-
def clean_analysis(analysis)
|
117
|
-
performed_analyses.delete_if { |e| e == analysis.name }
|
118
|
-
ongoing_analyses.delete_if { |e| e == analysis.name }
|
119
|
-
end
|
120
|
-
|
121
76
|
def clone
|
77
|
+
@entry.error = nil
|
122
78
|
if File.exist?(folder)
|
123
79
|
Rugged::Repository.new(folder)
|
124
80
|
else
|
125
81
|
Rugged::Repository.clone_at(url, folder)
|
126
82
|
end
|
127
|
-
|
128
|
-
self.error = nil
|
83
|
+
@entry.state = :cloned
|
129
84
|
rescue => e
|
130
85
|
Log.error "Error cloning #{url}."
|
131
|
-
|
86
|
+
@entry.error = e
|
132
87
|
end
|
133
88
|
|
134
89
|
def load_repository
|
135
|
-
fail "Source not cloned #{url}." if new?
|
90
|
+
fail "Source not cloned #{url}." if @entry.new?
|
136
91
|
@repository = Rugged::Repository.new(folder)
|
92
|
+
@repository.checkout("origin/master")
|
137
93
|
end
|
138
94
|
end
|
139
95
|
|
140
96
|
class Journal
|
141
|
-
|
97
|
+
attr_reader :sources, :workspace
|
98
|
+
|
99
|
+
def initialize
|
142
100
|
@sources = {}
|
143
|
-
@workspace =
|
144
|
-
hash[:urls].each do |u|
|
145
|
-
s = Source.new(u)
|
146
|
-
s.entry = hash[:sources][u] if !hash[:sources].nil? && hash[:sources].key?(u)
|
147
|
-
@sources[u] = s
|
148
|
-
end
|
149
|
-
@workspace = hash[:workspace]
|
150
|
-
@workspace = Journal.new_workspace_entry if hash[:workspace].nil? || hash[:workspace].empty?
|
101
|
+
@workspace = WorkspaceEntry.new
|
151
102
|
end
|
152
103
|
|
153
104
|
def sources
|
@@ -155,7 +106,7 @@ module Diggit
|
|
155
106
|
end
|
156
107
|
|
157
108
|
def sources_by_state(state, error = false)
|
158
|
-
@sources.select { |_u, s| s.state == state && s.error? == error }.values
|
109
|
+
@sources.select { |_u, s| s.entry.state == state && s.entry.error? == error }.values
|
159
110
|
end
|
160
111
|
|
161
112
|
def sources_by_ids(*ids)
|
@@ -169,56 +120,14 @@ module Diggit
|
|
169
120
|
result
|
170
121
|
end
|
171
122
|
|
172
|
-
def
|
173
|
-
|
174
|
-
@sources[source.url] = source
|
175
|
-
Dig.it.save_journal
|
123
|
+
def source?(url)
|
124
|
+
@sources.key?(url)
|
176
125
|
end
|
177
126
|
|
178
127
|
def add_source(url)
|
179
128
|
@sources[url] = Source.new(url) unless @sources.key?(url)
|
180
129
|
Dig.it.save_journal
|
181
130
|
end
|
182
|
-
|
183
|
-
def join?(name)
|
184
|
-
@workspace[:performed_joins].include?(name)
|
185
|
-
end
|
186
|
-
|
187
|
-
def add_join(name)
|
188
|
-
@workspace[:performed_joins] << name
|
189
|
-
Dig.it.save_journal
|
190
|
-
end
|
191
|
-
|
192
|
-
def join_error?
|
193
|
-
!@workspace[:last_error].nil?
|
194
|
-
end
|
195
|
-
|
196
|
-
def join_error
|
197
|
-
@workspace[:last_error]
|
198
|
-
end
|
199
|
-
|
200
|
-
def join_error=(error)
|
201
|
-
@workspace[:last_error] = Journal.dump_error(error)
|
202
|
-
Dig.it.save_journal
|
203
|
-
end
|
204
|
-
|
205
|
-
def to_hash
|
206
|
-
entry_hash = {}
|
207
|
-
@sources.each { |entry| entry_hash[entry[0]] = entry[1].entry }
|
208
|
-
{ urls: @sources.keys, sources: entry_hash, workspace: @workspace }
|
209
|
-
end
|
210
|
-
|
211
|
-
def self.new_source_entry
|
212
|
-
{ state: :new, performed_analyses: [], error_analyses: [], ongoing_analyses: [], last_error: {} }
|
213
|
-
end
|
214
|
-
|
215
|
-
def self.new_workspace_entry
|
216
|
-
{ performed_joins: [], last_error: {} }
|
217
|
-
end
|
218
|
-
|
219
|
-
def self.dump_error(error)
|
220
|
-
{ name: error.class.name, message: error.to_s, backtrace: error.backtrace }
|
221
|
-
end
|
222
131
|
end
|
223
132
|
|
224
133
|
class Config
|
@@ -249,6 +158,11 @@ module Diggit
|
|
249
158
|
Dig.it.save_config
|
250
159
|
end
|
251
160
|
|
161
|
+
def del_all_analyses
|
162
|
+
@analyses = []
|
163
|
+
Dig.it.save_config
|
164
|
+
end
|
165
|
+
|
252
166
|
def get_analyses(*names)
|
253
167
|
return analyses if names.empty?
|
254
168
|
analyses.select { |a| names.include?(a.simple_name) }
|
@@ -268,6 +182,11 @@ module Diggit
|
|
268
182
|
Dig.it.save_config
|
269
183
|
end
|
270
184
|
|
185
|
+
def del_all_joins
|
186
|
+
@joins = []
|
187
|
+
Dig.it.save_config
|
188
|
+
end
|
189
|
+
|
271
190
|
def get_joins(*names)
|
272
191
|
return joins if names.empty?
|
273
192
|
joins.select { |j| joins.include?(j.simple_name) }
|
@@ -416,7 +335,7 @@ module Diggit
|
|
416
335
|
Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
|
417
336
|
Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
|
418
337
|
FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
|
419
|
-
Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder),
|
338
|
+
Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
|
420
339
|
end
|
421
340
|
FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
|
422
341
|
unless File.exist?(File.expand_path("plugins", folder))
|
@@ -455,17 +374,17 @@ module Diggit
|
|
455
374
|
def load_journal
|
456
375
|
url_array = []
|
457
376
|
IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
|
458
|
-
|
459
|
-
|
460
|
-
|
377
|
+
@journal = Oj.load_file(config_path(DGIT_JOURNAL))
|
378
|
+
url_array.each do |url|
|
379
|
+
@journal.add_source(url)
|
380
|
+
end
|
461
381
|
end
|
462
382
|
|
463
383
|
# Save the journal to +.dgit/journal+
|
464
384
|
# @return [void]
|
465
385
|
def save_journal
|
466
|
-
|
467
|
-
|
468
|
-
Oj.to_file(config_path(DGIT_JOURNAL), { sources: hash[:sources], workspace: hash[:workspace] })
|
386
|
+
File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
|
387
|
+
Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
|
469
388
|
end
|
470
389
|
|
471
390
|
# Load the options from +.dgit/options+
|
@@ -497,7 +416,7 @@ module Diggit
|
|
497
416
|
# @param source_ids [Array<Integer>] the ids of the sources.
|
498
417
|
# @return [void]
|
499
418
|
def clone(*source_ids)
|
500
|
-
@journal.sources_by_ids(*source_ids).select
|
419
|
+
@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
|
501
420
|
ensure
|
502
421
|
save_journal
|
503
422
|
end
|
@@ -508,13 +427,13 @@ module Diggit
|
|
508
427
|
# @param mode [Symbol] the mode: +:run+, +:rerun+ or +:clean+.
|
509
428
|
# @return [void]
|
510
429
|
def analyze(source_ids = [], analyses = [], mode = :run)
|
511
|
-
@journal.sources_by_ids(*source_ids).select
|
430
|
+
@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
|
512
431
|
@config.get_analyses(*analyses).each do |klass|
|
513
432
|
a = klass.new(@options)
|
514
433
|
s.load_repository
|
515
434
|
a.source = s
|
516
|
-
|
517
|
-
|
435
|
+
clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
|
436
|
+
run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
|
518
437
|
end
|
519
438
|
end
|
520
439
|
end
|
@@ -527,11 +446,12 @@ module Diggit
|
|
527
446
|
def join(source_ids = [], joins = [], mode = :run)
|
528
447
|
@config.get_joins(*joins).each do |klass|
|
529
448
|
j = klass.new(@options)
|
530
|
-
j.
|
449
|
+
clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
|
531
450
|
source_array = @journal.sources_by_ids(*source_ids).select do |s|
|
532
|
-
s.cloned? && (klass.required_analyses - s.
|
451
|
+
s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
|
533
452
|
end
|
534
|
-
|
453
|
+
j.sources = source_array
|
454
|
+
run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
|
535
455
|
end
|
536
456
|
end
|
537
457
|
|
@@ -545,34 +465,36 @@ module Diggit
|
|
545
465
|
mode == :rerun || mode == :run
|
546
466
|
end
|
547
467
|
|
548
|
-
def
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
Log.error "Error applying analysis #{a.name} on #{s.url}"
|
562
|
-
s.error = Journal.dump_error(e)
|
563
|
-
ensure
|
564
|
-
save_journal
|
468
|
+
def clean(runnable, placeholder)
|
469
|
+
placeholder.clean(runnable)
|
470
|
+
entry = RunnableEntry.new(runnable)
|
471
|
+
begin
|
472
|
+
runnable.clean
|
473
|
+
rescue => e
|
474
|
+
entry.toc
|
475
|
+
entry.error = e
|
476
|
+
placeholder.canceled << entry
|
477
|
+
Log.error "Error cleaning #{runnable.name}"
|
478
|
+
ensure
|
479
|
+
save_journal
|
480
|
+
end
|
565
481
|
end
|
566
482
|
|
567
|
-
def
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
483
|
+
def run(runnable, placeholder)
|
484
|
+
entry = RunnableEntry.new(runnable)
|
485
|
+
begin
|
486
|
+
runnable.run
|
487
|
+
rescue => e
|
488
|
+
entry.toc
|
489
|
+
entry.error = e
|
490
|
+
placeholder.canceled << entry
|
491
|
+
Log.error "Error running #{runnable.name}"
|
492
|
+
else
|
493
|
+
entry.toc
|
494
|
+
placeholder.performed << entry
|
495
|
+
ensure
|
496
|
+
save_journal
|
497
|
+
end
|
576
498
|
end
|
577
499
|
end
|
578
500
|
end
|
data/lib/dgit/entries.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This file is part of Diggit.
|
4
|
+
#
|
5
|
+
# Diggit is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Diggit is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
19
|
+
|
20
|
+
module Diggit
|
21
|
+
# Journal entry for elements that can have error.
|
22
|
+
#
|
23
|
+
# @!attribute [r] error
|
24
|
+
# @return [ErrorEntry, nil] the error entry.
|
25
|
+
module EntryWithError
|
26
|
+
attr_reader :error
|
27
|
+
|
28
|
+
# Set the error of the entry.
|
29
|
+
# @param e [Exception, nil] the error, to indicate an absence of error, pass +nil+.
|
30
|
+
# @return [void]
|
31
|
+
def error=(e)
|
32
|
+
if e.nil?
|
33
|
+
@error = nil
|
34
|
+
else
|
35
|
+
@error = ErrorEntry.new(e)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Journal entry for elements that can launch runnables.
|
41
|
+
#
|
42
|
+
# @!attribute [r] performed
|
43
|
+
# @return [Array<RunnableEntry>] the list of performed runnables.
|
44
|
+
# @!attribute [r] canceled
|
45
|
+
# @return [Array<RunnableEntry>] the list of canceled runnables.
|
46
|
+
class EntryWithRunnables
|
47
|
+
attr_reader :performed, :canceled
|
48
|
+
|
49
|
+
def initialize
|
50
|
+
@performed = []
|
51
|
+
@canceled = []
|
52
|
+
end
|
53
|
+
|
54
|
+
# Error status of the element.
|
55
|
+
# @return [Boolean]
|
56
|
+
def error?
|
57
|
+
@canceled.size > 0
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check if a runnable has been performed or canceled.
|
61
|
+
# @param runnable_or_string [Runnable, String] the runnable or the name of the runnable.
|
62
|
+
# @param state [Symbol] the status of the runnable: +:performed+, +:canceled+ or +:all+.
|
63
|
+
# @return [Boolean]
|
64
|
+
def has?(runnable_or_string, state = :all)
|
65
|
+
name = retrieve_name(runnable_or_string)
|
66
|
+
if state == :performed
|
67
|
+
return @performed.count { |e| e.name == name } > 0
|
68
|
+
elsif state == :canceled
|
69
|
+
return @canceled.count { |e| e.name == name } > 0
|
70
|
+
elsif state == :all
|
71
|
+
return (@performed + @canceled).count { |e| e.name == name } > 0
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Remove a runnable from all the entries.
|
76
|
+
# @param runnable_or_string [Runnable, String] the runnable or the name of the runnable
|
77
|
+
# @return [void]
|
78
|
+
def clean(runnable_or_string)
|
79
|
+
name = retrieve_name(runnable_or_string)
|
80
|
+
@performed.delete_if { |e| e.name == name }
|
81
|
+
@canceled.delete_if { |e| e.name == name }
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
def retrieve_name(runnable_or_string)
|
87
|
+
if runnable_or_string.is_a? String
|
88
|
+
return runnable_or_string
|
89
|
+
else
|
90
|
+
return runnable_or_string.name
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class ErrorEntry
|
96
|
+
attr_reader :name, :message, :backtrace
|
97
|
+
|
98
|
+
def initialize(error)
|
99
|
+
@name = error.class.name
|
100
|
+
@message = error.to_s
|
101
|
+
@backtrace = error.backtrace
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class RunnableEntry
|
106
|
+
include EntryWithError
|
107
|
+
attr_accessor :start, :end, :name
|
108
|
+
|
109
|
+
def initialize(runnable)
|
110
|
+
@name = runnable.name
|
111
|
+
@end = nil
|
112
|
+
tic
|
113
|
+
end
|
114
|
+
|
115
|
+
def error?
|
116
|
+
!@error.nil?
|
117
|
+
end
|
118
|
+
|
119
|
+
def tic
|
120
|
+
@start = Time.now
|
121
|
+
end
|
122
|
+
|
123
|
+
def toc
|
124
|
+
@end = Time.now
|
125
|
+
end
|
126
|
+
|
127
|
+
def duration
|
128
|
+
@end - @start
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
class SourceEntry < EntryWithRunnables
|
133
|
+
include EntryWithError
|
134
|
+
attr_accessor :state
|
135
|
+
|
136
|
+
def initialize
|
137
|
+
super
|
138
|
+
@state = :new
|
139
|
+
end
|
140
|
+
|
141
|
+
def error?
|
142
|
+
super || !@error.nil?
|
143
|
+
end
|
144
|
+
|
145
|
+
def new?
|
146
|
+
@state == :new
|
147
|
+
end
|
148
|
+
|
149
|
+
def cloned?
|
150
|
+
@state == :cloned
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
class WorkspaceEntry < EntryWithRunnables
|
155
|
+
def initialize
|
156
|
+
super
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
data/lib/dgit/version.rb
CHANGED
data/plugins/analysis/cloc.rb
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This file is part of Diggit.
|
4
|
+
#
|
5
|
+
# Diggit is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Diggit is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
19
|
+
|
20
|
+
require 'jsonpath'
|
21
|
+
|
22
|
+
class Javadoc < Diggit::Analysis
|
23
|
+
def initialize(options)
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
path_md = JsonPath.new("$..*[?(@.typeLabel == 'MethodDeclaration')]")
|
29
|
+
files = Dir['**/*.java']
|
30
|
+
files.each do |file|
|
31
|
+
puts file
|
32
|
+
json = `gumtree parse "#{file}"`
|
33
|
+
md = path_md.on(json)
|
34
|
+
md.each do |m|
|
35
|
+
puts m
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def clean
|
42
|
+
end
|
43
|
+
end
|
data/plugins/analysis/tex.rb
CHANGED
data/spec/core_spec.rb
CHANGED
@@ -100,7 +100,7 @@ RSpec.describe Diggit::Dig do
|
|
100
100
|
Diggit::Dig.it.clone
|
101
101
|
expect(File.exist?("spec/dgit/sources/#{TEST_URL.id}/.git")).to be true
|
102
102
|
expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
|
103
|
-
Diggit::Dig.it.journal.sources_by_ids(0)[0].state = :new
|
103
|
+
Diggit::Dig.it.journal.sources_by_ids(0)[0].entry.state = :new
|
104
104
|
Diggit::Dig.it.clone
|
105
105
|
expect(Diggit::Dig.it.journal.sources_by_ids(0)[0].url).to eq TEST_URL
|
106
106
|
Diggit::Dig.init("spec/dgit")
|
@@ -113,18 +113,23 @@ RSpec.describe Diggit::Dig do
|
|
113
113
|
Diggit::Dig.it.config.add_analysis("test_analysis_with_addon")
|
114
114
|
expect_any_instance_of(TestAnalysisWithAddon).to receive(:run)
|
115
115
|
Diggit::Dig.it.analyze
|
116
|
-
|
116
|
+
src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
|
117
|
+
expect(src.entry.has?("test_analysis", :performed)).to be true
|
118
|
+
expect(src.entry.has?("test_analysis_with_addon", :performed)).to be true
|
117
119
|
Diggit::Dig.init("spec/dgit")
|
118
|
-
|
120
|
+
src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
|
121
|
+
expect(src.entry.has?("test_analysis", :performed)).to be true
|
122
|
+
expect(src.entry.has?("test_analysis_with_addon", :performed)).to be true
|
119
123
|
end
|
120
124
|
|
121
125
|
it "should handle analyses with error" do
|
122
126
|
Diggit::Dig.it.config.add_analysis("test_analysis_with_error")
|
123
127
|
Diggit::Dig.it.analyze
|
124
128
|
src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
|
125
|
-
expect(src.
|
126
|
-
expect(src.
|
127
|
-
expect(src.error
|
129
|
+
expect(src.entry.has?("test_analysis_with_error", :performed)).to be false
|
130
|
+
expect(src.entry.has?("test_analysis_with_error", :canceled)).to be true
|
131
|
+
expect(src.entry.error?).to be true
|
132
|
+
expect(src.entry.canceled[0].error.message).to eq("Error!")
|
128
133
|
end
|
129
134
|
|
130
135
|
it "should perform joins" do
|
@@ -133,21 +138,55 @@ RSpec.describe Diggit::Dig do
|
|
133
138
|
expect_any_instance_of(TestJoin).to receive(:run)
|
134
139
|
expect_any_instance_of(TestJoinWithAddon).not_to receive(:run)
|
135
140
|
Diggit::Dig.it.join
|
136
|
-
expect(Diggit::Dig.it.journal.
|
137
|
-
expect(Diggit::Dig.it.journal.
|
141
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join", :performed)).to be true
|
142
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_addon", :performed)).to be false
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should handle joins with error" do
|
146
|
+
Diggit::Dig.it.config.add_join("test_join_with_error")
|
147
|
+
Diggit::Dig.it.join
|
148
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_error", :performed)).to be false
|
149
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_error", :canceled)).to be true
|
150
|
+
expect(Diggit::Dig.it.journal.workspace.error?).to be true
|
151
|
+
expect(Diggit::Dig.it.journal.workspace.canceled[0].error.message).to eq("Error!")
|
138
152
|
end
|
139
153
|
|
140
154
|
it "should clean joins" do
|
141
155
|
expect_any_instance_of(TestJoin).to receive(:clean)
|
142
|
-
expect_any_instance_of(TestJoinWithAddon).
|
156
|
+
expect_any_instance_of(TestJoinWithAddon).not_to receive(:clean)
|
143
157
|
Diggit::Dig.it.join([], [], :clean)
|
158
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join")).to be false
|
159
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_addon")).to be false
|
160
|
+
Diggit::Dig.it.config.del_all_joins
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should handle joins with clean errors" do
|
164
|
+
Diggit::Dig.it.config.add_join("test_join_with_clean_error")
|
165
|
+
Diggit::Dig.it.join
|
166
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_clean_error", :performed)).to be true
|
167
|
+
Diggit::Dig.it.join([], [], :clean)
|
168
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_clean_error", :performed)).to be false
|
169
|
+
expect(Diggit::Dig.it.journal.workspace.has?("test_join_with_clean_error", :canceled)).to be true
|
144
170
|
end
|
145
171
|
|
146
172
|
it "should clean analyses" do
|
147
173
|
expect_any_instance_of(TestAnalysis).to receive(:clean)
|
148
174
|
expect_any_instance_of(TestAnalysisWithAddon).to receive(:clean)
|
149
175
|
Diggit::Dig.it.analyze([], [], :clean)
|
150
|
-
|
176
|
+
src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
|
177
|
+
expect(src.entry.has?("test_analysis")).to be false
|
178
|
+
expect(src.entry.has?("test_analysis_with_addon")).to be false
|
179
|
+
Diggit::Dig.it.config.del_all_analyses
|
180
|
+
end
|
181
|
+
|
182
|
+
it "should handle analyses with clean errors" do
|
183
|
+
Diggit::Dig.it.config.add_analysis("test_analysis_with_clean_error")
|
184
|
+
Diggit::Dig.it.analyze([], ["test_analysis_with_clean_error"])
|
185
|
+
src = Diggit::Dig.it.journal.sources_by_ids(0)[0]
|
186
|
+
expect(src.entry.has?("test_analysis_with_clean_error", :performed)).to be true
|
187
|
+
Diggit::Dig.it.analyze([], [], :clean)
|
188
|
+
expect(src.entry.has?("test_analysis_with_clean_error", :performed)).to be false
|
189
|
+
expect(src.entry.has?("test_analysis_with_clean_error", :canceled)).to be true
|
151
190
|
end
|
152
191
|
|
153
192
|
it "should read source options" do
|
@@ -161,7 +200,6 @@ RSpec.describe Diggit::Dig do
|
|
161
200
|
|
162
201
|
Diggit::Dig.it.config.add_analysis("test_analysis_with_sources_options")
|
163
202
|
expect { Diggit::Dig.it.analyze }.to output(/myValue/).to_stdout
|
164
|
-
Diggit::Dig.it.
|
165
|
-
Diggit::Dig.it.config.del_analysis("test_analysis_with_sources_options")
|
203
|
+
Diggit::Dig.it.config.del_all_analyses
|
166
204
|
end
|
167
205
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This file is part of Diggit.
|
4
|
+
#
|
5
|
+
# Diggit is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Diggit is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
19
|
+
|
20
|
+
class TestAnalysisWithCleanError < Diggit::Analysis
|
21
|
+
def run
|
22
|
+
end
|
23
|
+
|
24
|
+
def clean
|
25
|
+
fail "Error!"
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This file is part of Diggit.
|
4
|
+
#
|
5
|
+
# Diggit is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Diggit is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
19
|
+
|
20
|
+
class TestJoinWithCleanError < Diggit::Join
|
21
|
+
require_analyses 'test_analysis'
|
22
|
+
|
23
|
+
def run
|
24
|
+
end
|
25
|
+
|
26
|
+
def clean
|
27
|
+
fail "Error!"
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# This file is part of Diggit.
|
4
|
+
#
|
5
|
+
# Diggit is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU Lesser General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# Diggit is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License
|
16
|
+
# along with Diggit. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
#
|
18
|
+
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
19
|
+
|
20
|
+
class TestJoinWithError < Diggit::Join
|
21
|
+
require_analyses 'test_analysis'
|
22
|
+
|
23
|
+
def run
|
24
|
+
fail "Error!"
|
25
|
+
end
|
26
|
+
|
27
|
+
def clean
|
28
|
+
end
|
29
|
+
end
|
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: 2.0
|
4
|
+
version: 2.1.0
|
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: 2015-
|
12
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rugged
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- bin/dgit
|
168
168
|
- lib/dgit.rb
|
169
169
|
- lib/dgit/core.rb
|
170
|
+
- lib/dgit/entries.rb
|
170
171
|
- lib/dgit/log.rb
|
171
172
|
- lib/dgit/plugins.rb
|
172
173
|
- lib/dgit/version.rb
|
@@ -176,6 +177,7 @@ files:
|
|
176
177
|
- plugins/addon/src_opt.rb
|
177
178
|
- plugins/analysis/cloc.rb
|
178
179
|
- plugins/analysis/cloc_per_file.rb
|
180
|
+
- plugins/analysis/javadoc.rb
|
179
181
|
- plugins/analysis/tex.rb
|
180
182
|
- spec/core_spec.rb
|
181
183
|
- spec/dgit/plugins/addon/test_addon.rb
|
@@ -184,10 +186,13 @@ files:
|
|
184
186
|
- spec/dgit/plugins/analysis/my_module/other_analysis.rb
|
185
187
|
- spec/dgit/plugins/analysis/test_analysis.rb
|
186
188
|
- spec/dgit/plugins/analysis/test_analysis_with_addon.rb
|
189
|
+
- spec/dgit/plugins/analysis/test_analysis_with_clean_error.rb
|
187
190
|
- spec/dgit/plugins/analysis/test_analysis_with_error.rb
|
188
191
|
- spec/dgit/plugins/analysis/test_analysis_with_sources_options.rb
|
189
192
|
- spec/dgit/plugins/join/test_join.rb
|
190
193
|
- spec/dgit/plugins/join/test_join_with_addon.rb
|
194
|
+
- spec/dgit/plugins/join/test_join_with_clean_error.rb
|
195
|
+
- spec/dgit/plugins/join/test_join_with_error.rb
|
191
196
|
- spec/spec_helper.rb
|
192
197
|
homepage: https://github.com/jrfaller/diggit
|
193
198
|
licenses:
|