octostat 0.3.0 → 0.4.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 +14 -0
- data/Rakefile +1 -1
- data/exe/octostat +2 -2
- data/lib/octostat/command.rb +14 -5
- data/lib/octostat/database.rb +8 -8
- data/lib/octostat/git.rb +16 -4
- data/lib/octostat/version.rb +1 -1
- metadata +3 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5233f9bbf3702251a2914d07093caab07a8aeaf5461f970027237c6c6ea0f301
|
4
|
+
data.tar.gz: d9171098a6fdc823d91bb7254028f5092ca1c197d14002c69369551554d7c4a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994ca4fe6a5531b57f22144dfb31eac32be8a05c4fc0b3b14a5ede3de5e15d8e9ab26bb75af6192cf590bc05e9d338a1f70ff295381b6439830344ba14b73a54
|
7
|
+
data.tar.gz: 5998dcefbd49b274acd2035e8214ecf1e21fa5b5fd05d8ee24d924fe9be7eb01be05bcfcd8703cbe8d3d940de12a01a5e3d3fffcd0ae3a80dce845ae613e9987
|
data/CHANGELOG.md
ADDED
data/Rakefile
CHANGED
data/exe/octostat
CHANGED
data/lib/octostat/command.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require "optparse"
|
3
2
|
|
4
3
|
module Octostat
|
5
4
|
class Command
|
@@ -7,18 +6,28 @@ module Octostat
|
|
7
6
|
@db_path = "octostat.sqlite"
|
8
7
|
args = parser.parse!(args)
|
9
8
|
@path = args.first || Dir.pwd
|
9
|
+
@batch_size = 1000
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
13
|
db = Database.new(db_path)
|
14
|
-
Git.new(path)
|
15
|
-
|
14
|
+
@git = Git.new(path)
|
15
|
+
git.each_slice(batch_size).with_index do |commits, batch|
|
16
|
+
puts_progress batch * batch_size
|
17
|
+
commits.each { |commit| db.insert_commit(**commit) }
|
16
18
|
end
|
19
|
+
puts_progress git.count
|
20
|
+
puts "\nDone!"
|
17
21
|
end
|
18
22
|
|
19
23
|
private
|
20
24
|
|
21
|
-
attr_reader :db_path, :path
|
25
|
+
attr_reader :db_path, :path, :batch_size, :git
|
26
|
+
|
27
|
+
def puts_progress processed
|
28
|
+
print "\r#{(processed.to_f / git.count.to_f * 100).ceil}%"
|
29
|
+
$stdout.flush
|
30
|
+
end
|
22
31
|
|
23
32
|
def parser
|
24
33
|
OptionParser.new do |opts|
|
data/lib/octostat/database.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "forwardable"
|
2
2
|
require "sqlite3"
|
3
3
|
|
4
4
|
module Octostat
|
@@ -6,12 +6,12 @@ module Octostat
|
|
6
6
|
extend Forwardable
|
7
7
|
|
8
8
|
PRAGMAS = {
|
9
|
-
"foreign_keys"
|
10
|
-
"journal_mode"
|
11
|
-
"synchronous"
|
12
|
-
"mmap_size"
|
13
|
-
"journal_size_limit"
|
14
|
-
"cache_size"
|
9
|
+
"foreign_keys" => true,
|
10
|
+
"journal_mode" => :wal,
|
11
|
+
"synchronous" => :normal,
|
12
|
+
"mmap_size" => 134217728, # 128 megabytes
|
13
|
+
"journal_size_limit" => 67108864, # 64 megabytes
|
14
|
+
"cache_size" => 2000
|
15
15
|
}
|
16
16
|
|
17
17
|
COMMIT_INSERT = "INSERT OR IGNORE INTO commits (hash, email, name, date, merge_commit, subject) VALUES (?, ?, ?, ?, ?, ?)"
|
@@ -56,7 +56,7 @@ module Octostat
|
|
56
56
|
|
57
57
|
def apply_pragma
|
58
58
|
PRAGMAS.each do |pragma, value|
|
59
|
-
db.public_send("#{pragma}=", value)
|
59
|
+
db.public_send(:"#{pragma}=", value)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
data/lib/octostat/git.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "open3"
|
2
|
-
|
2
|
+
require "tmpdir"
|
3
3
|
|
4
4
|
module Octostat
|
5
5
|
class Git
|
@@ -16,19 +16,25 @@ module Octostat
|
|
16
16
|
|
17
17
|
ENTRY_LENGTH = LOG_FORMAT.lines.size
|
18
18
|
|
19
|
-
|
19
|
+
LIST_COMMAND = ["git", "log", "--pretty=format:#{LOG_FORMAT}"]
|
20
|
+
COUNT_COMMAND = ["git", "rev-list", "--count", "HEAD"]
|
21
|
+
CLONE_COMMAND = ["git", "clone"]
|
20
22
|
|
21
23
|
def initialize path
|
22
|
-
@path = path
|
24
|
+
@path = Dir.exist?(path) ? path : clone_repo(path)
|
23
25
|
end
|
24
26
|
|
25
27
|
def env
|
26
28
|
{"GIT_DIR" => path}
|
27
29
|
end
|
28
30
|
|
31
|
+
def count
|
32
|
+
@count ||= Open3.capture2(*COUNT_COMMAND, chdir: path).first.to_i
|
33
|
+
end
|
34
|
+
|
29
35
|
def each
|
30
36
|
return enum_for(:each) unless block_given?
|
31
|
-
Open3.popen2e(*
|
37
|
+
Open3.popen2e(*LIST_COMMAND, chdir: path) do |input, output, wait_thr|
|
32
38
|
output.each_slice(ENTRY_LENGTH) do |commit|
|
33
39
|
commit.each(&:strip!)
|
34
40
|
hash, email, name, date, parents, subject = commit
|
@@ -47,6 +53,12 @@ module Octostat
|
|
47
53
|
|
48
54
|
private
|
49
55
|
|
56
|
+
def clone_repo upstream
|
57
|
+
repo_path = Dir.mktmpdir
|
58
|
+
Open3.capture2(*CLONE_COMMAND, upstream, repo_path)
|
59
|
+
repo_path
|
60
|
+
end
|
61
|
+
|
50
62
|
attr_reader :path
|
51
63
|
end
|
52
64
|
end
|
data/lib/octostat/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octostat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joé Dupuis
|
@@ -24,48 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: debug
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
27
|
description:
|
70
28
|
email:
|
71
29
|
- joe@dupuis.io
|
@@ -74,6 +32,7 @@ executables:
|
|
74
32
|
extensions: []
|
75
33
|
extra_rdoc_files: []
|
76
34
|
files:
|
35
|
+
- CHANGELOG.md
|
77
36
|
- LICENSE.txt
|
78
37
|
- README.md
|
79
38
|
- Rakefile
|
@@ -89,7 +48,7 @@ licenses:
|
|
89
48
|
metadata:
|
90
49
|
homepage_uri: https://github.com/testdouble/octostat
|
91
50
|
source_code_uri: https://github.com/testdouble/octostat
|
92
|
-
changelog_uri: https://github.com/testdouble/octostat/main/CHANGELOG.md
|
51
|
+
changelog_uri: https://github.com/testdouble/octostat/blob/main/CHANGELOG.md
|
93
52
|
post_install_message:
|
94
53
|
rdoc_options: []
|
95
54
|
require_paths:
|