git_miner 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/git-mine +18 -3
- data/lib/git_miner.rb +8 -0
- data/lib/git_miner/core.rb +8 -7
- data/lib/git_miner/git_util.rb +4 -4
- data/lib/git_miner/progress.rb +4 -4
- data/lib/git_miner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12c481503abcbd3c633ab3ed3712a97b1b2d88388c7db2daf1473aab5dd9d886
|
4
|
+
data.tar.gz: 8a013d2c312f323b61e322d756884c4b7d4da2235ccdc5f55d0a87293a479952
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 268ad9f06a85504d18bea84347e08b315e2c34f1d88ab4d8b2cd268accc3544a1ff36ec8afe17f4344dddc60d8b2aa6201230d4144511f873a2297da9a3be654
|
7
|
+
data.tar.gz: 1439261df54c6c8235c8a6b47fd4dff175c962803083bf2ff02e711e6d405cb161a459113754a9cf0582cdbe8aaae1cf3052c838b838bca8f60bec3b1899435f
|
data/bin/git-mine
CHANGED
@@ -12,7 +12,7 @@ options = {
|
|
12
12
|
dispatch: :parallel,
|
13
13
|
}
|
14
14
|
|
15
|
-
OptionParser.new do |opts|
|
15
|
+
parser = OptionParser.new do |opts|
|
16
16
|
opts.banner = "Usage: example.rb [options]"
|
17
17
|
|
18
18
|
opts.on("--engine [ruby|c]", [:ruby, :c], "Set the engine (default: ruby)") do |x|
|
@@ -23,17 +23,32 @@ OptionParser.new do |opts|
|
|
23
23
|
options[:dispatch] = x
|
24
24
|
end
|
25
25
|
|
26
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely (default: false)") do |v|
|
27
|
+
options[:verbose] = v
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on_tail("--version", "Returns the current version") do |v|
|
31
|
+
puts "GitMiner #{GitMiner::VERSION}"
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
26
35
|
opts.on_tail("-h", "--help", "Show this message") do
|
27
36
|
puts opts
|
28
37
|
exit
|
29
38
|
end
|
30
|
-
end
|
39
|
+
end
|
40
|
+
|
41
|
+
parser.parse!
|
31
42
|
|
32
43
|
unless ARGV.size == 1
|
33
|
-
puts
|
44
|
+
puts parser
|
34
45
|
exit 1
|
35
46
|
end
|
36
47
|
|
48
|
+
GitMiner.logger.level = options[:verbose] ? Logger::DEBUG : Logger::INFO
|
49
|
+
|
50
|
+
GitMiner.logger.debug("OptionParser: #{options.inspect}")
|
51
|
+
|
37
52
|
prefix = ARGV.first
|
38
53
|
|
39
54
|
engine = case(options[:engine])
|
data/lib/git_miner.rb
CHANGED
data/lib/git_miner/core.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module GitMiner
|
2
2
|
class Core
|
3
3
|
def initialize(engine:, dispatch:, prefix:)
|
4
|
-
|
4
|
+
GitMiner.logger.debug("Initializing with engine '#{engine}'. dispatch '#{dispatch}' and prefix '#{prefix}'")
|
5
5
|
|
6
6
|
@prefix = prefix
|
7
7
|
|
@@ -38,11 +38,11 @@ module GitMiner
|
|
38
38
|
raise "Invalid prefix, expected '^[0-9a-f]{1,32}$'"
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
GitMiner.logger.debug("Validations: Successful")
|
42
42
|
end
|
43
43
|
|
44
44
|
def mine
|
45
|
-
|
45
|
+
GitMiner.logger.info("Mining for SHA: #{@prefix}")
|
46
46
|
|
47
47
|
@mining_result = @dispatch.execute
|
48
48
|
end
|
@@ -50,10 +50,11 @@ module GitMiner
|
|
50
50
|
def report
|
51
51
|
raise "Prerequisite: Require mining to be completed first" unless @mining_result
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
GitMiner.logger.debug("Mining completed.")
|
54
|
+
GitMiner.logger.debug("Author offset: #{@mining_result.author_offset}")
|
55
|
+
GitMiner.logger.debug("Committer offset: #{@mining_result.committer_offset}")
|
56
|
+
|
57
|
+
GitMiner.logger.info("New SHA: #{@mining_result.sha}")
|
57
58
|
end
|
58
59
|
|
59
60
|
def alter
|
data/lib/git_miner/git_util.rb
CHANGED
@@ -34,9 +34,9 @@ module GitMiner
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def shell(cmd, environment: {}, stdin_data: nil)
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
GitMiner.logger.debug("System call: #{cmd}")
|
38
|
+
GitMiner.logger.debug("environment: #{environment.inspect}") unless environment.empty?
|
39
|
+
GitMiner.logger.debug("stdin_data: #{stdin_data}") if stdin_data
|
40
40
|
|
41
41
|
output, status = Open3.capture2(environment, cmd, stdin_data: stdin_data) #, chdir: @working_directory
|
42
42
|
|
@@ -44,7 +44,7 @@ module GitMiner
|
|
44
44
|
raise "Error on system call: #{output}, #{status}"
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
GitMiner.logger.debug("result: #{output.strip}")
|
48
48
|
|
49
49
|
output
|
50
50
|
end
|
data/lib/git_miner/progress.rb
CHANGED
@@ -31,19 +31,19 @@ module GitMiner
|
|
31
31
|
info = []
|
32
32
|
|
33
33
|
percentage = count * 100 / @combinations.to_f
|
34
|
-
info << "#{percentage
|
34
|
+
info << "#{'%.2f' % percentage}%"
|
35
35
|
|
36
36
|
historic_count = @historic.last[:count] - @historic.first[:count]
|
37
37
|
historic_delay = @historic.last[:timestamp] - @historic.first[:timestamp]
|
38
38
|
if historic_delay > 0
|
39
39
|
per_sec = historic_count / historic_delay
|
40
|
-
info << "hash: #{per_sec
|
40
|
+
info << "hash: #{'%.2f' % per_sec}/s"
|
41
41
|
|
42
42
|
per_sec = (@historic.last[:batch] - @historic.first[:batch]) / historic_delay
|
43
|
-
info << "batches: #{per_sec
|
43
|
+
info << "batches: #{'%.2f' % per_sec}/s"
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
GitMiner.logger.info(info.join(', '))
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/git_miner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_miner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thierry Joyal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parallel
|