churned 0.1.3 → 0.2.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/Gemfile.lock +3 -3
- data/bin/console +1 -0
- data/bin/debug +17 -0
- data/config/database.rb +19 -0
- data/exe/churned +2 -0
- data/lib/churned/cli.rb +0 -1
- data/lib/churned/command.rb +5 -0
- data/lib/churned/commands/console.rb +1 -0
- data/lib/churned/commands/db/create.rb +39 -0
- data/lib/churned/commands/db/load.rb +34 -0
- data/lib/churned/commands/db.rb +21 -0
- data/lib/churned/commands/install.rb +4 -38
- data/lib/churned/templates/db/create/.gitkeep +1 -0
- data/lib/churned/templates/db/load/.gitkeep +1 -0
- data/lib/churned/version.rb +1 -1
- data/lib/churned.rb +1 -4
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdbda526e18257f230ce6d34a512d719d34b77489d55f07099f1649bbaac337e
|
4
|
+
data.tar.gz: 72e9e1690105e3a38f28e37bb1802d2514f256545532e65346c5fc830cd48dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff3b3edfa9f85ca918e8cb2fe5960cec0ae50e3000a237334dff4ed12e721b39c37c54f8f5ead25f794fcbbc01f8de417649faee0da0f8bea813c5a3707f7d00
|
7
|
+
data.tar.gz: d4bbd9cbcb1c3c8d66bc15daa6f540cc834e628772d18e71c29ee33d4fb5c9af0e960117a1408d3d712bb1023b176a2704534379a8c8c4e6d8b2f9a6ec86396a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
churned (0.
|
4
|
+
churned (0.2.0)
|
5
5
|
activerecord (~> 6.1)
|
6
6
|
pry
|
7
7
|
sqlite3
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
concurrent-ruby (1.1.9)
|
29
29
|
diff-lcs (1.4.4)
|
30
30
|
equatable (0.7.0)
|
31
|
-
i18n (1.8.
|
31
|
+
i18n (1.8.11)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
method_source (1.0.0)
|
34
34
|
minitest (5.14.4)
|
@@ -62,7 +62,7 @@ GEM
|
|
62
62
|
tzinfo (2.0.4)
|
63
63
|
concurrent-ruby (~> 1.0)
|
64
64
|
wisper (2.0.1)
|
65
|
-
zeitwerk (2.
|
65
|
+
zeitwerk (2.5.1)
|
66
66
|
|
67
67
|
PLATFORMS
|
68
68
|
ruby
|
data/bin/console
CHANGED
data/bin/debug
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
ENV["TTY_ENV"] = "development"
|
4
|
+
require "bundler/setup"
|
5
|
+
require "churned"
|
6
|
+
|
7
|
+
Signal.trap('INT') do
|
8
|
+
warn("\n#{caller.join("\n")}: interrupted")
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
|
12
|
+
begin
|
13
|
+
Churned::CLI.start
|
14
|
+
rescue Churned::CLI::Error => err
|
15
|
+
puts "ERROR: #{err.message}"
|
16
|
+
exit 1
|
17
|
+
end
|
data/config/database.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "sqlite3"
|
3
|
+
|
4
|
+
module Churned
|
5
|
+
def db_config
|
6
|
+
{
|
7
|
+
"production" => { "database_name" => ".churned/db.sqlite" },
|
8
|
+
"test" => { "database_name" => ".churned/db_test.sqlite" },
|
9
|
+
"development" => { "database_name" => ".churned/db_development.sqlite" },
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def database
|
14
|
+
db_config[ENV["TTY_ENV"]]["database_name"]
|
15
|
+
end
|
16
|
+
module_function :db_config, :database
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: Churned.database)
|
data/exe/churned
CHANGED
data/lib/churned/cli.rb
CHANGED
data/lib/churned/command.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../command'
|
4
|
+
|
5
|
+
module Churned
|
6
|
+
module Commands
|
7
|
+
module DB
|
8
|
+
class Create < Churned::Command
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.execute
|
14
|
+
new({}).execute(input: $stdin, output: $stdout)
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute(input: $stdin, output: $stdout)
|
18
|
+
generator.create_dir(".churned")
|
19
|
+
|
20
|
+
ActiveRecord::Schema.define do
|
21
|
+
create_table :commits, force: true do |t|
|
22
|
+
t.string :sha
|
23
|
+
t.string :author
|
24
|
+
t.date :author_date
|
25
|
+
end
|
26
|
+
|
27
|
+
create_table :file_changes, force: true do |t|
|
28
|
+
t.references :commit
|
29
|
+
t.string :pathname
|
30
|
+
t.integer :additions, default: 0
|
31
|
+
t.integer :deletions, default: 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../command'
|
4
|
+
|
5
|
+
module Churned
|
6
|
+
module Commands
|
7
|
+
module DB
|
8
|
+
class Load < Churned::Command
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.execute(filename)
|
14
|
+
new({}).execute(filename, input: $stdin, output: $stdout)
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute(filename, input: $stdin, output: $stdout)
|
18
|
+
IO.read(filename).split("\n\n").each do |description|
|
19
|
+
sha, date, author, *numstats = description.split("\n")
|
20
|
+
|
21
|
+
commit = Commit.new(sha: sha, author_date: date, author: author)
|
22
|
+
|
23
|
+
numstats.each do |numstat|
|
24
|
+
additions, deletions, pathname = numstat.split("\t")
|
25
|
+
commit.file_changes.build(additions: additions, deletions: deletions, pathname: pathname)
|
26
|
+
end
|
27
|
+
|
28
|
+
commit.save
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require_relative 'db/load'
|
5
|
+
require_relative 'db/create'
|
6
|
+
|
7
|
+
module Churned
|
8
|
+
module Commands
|
9
|
+
module DB
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def create
|
13
|
+
Create.execute
|
14
|
+
end
|
15
|
+
|
16
|
+
def load(filename)
|
17
|
+
Load.execute(filename)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -9,44 +9,10 @@ module Churned
|
|
9
9
|
@options = options
|
10
10
|
end
|
11
11
|
|
12
|
-
def execute(input: $stdin, output: $stdout)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ".churned/database")
|
17
|
-
|
18
|
-
ActiveRecord::Schema.define do
|
19
|
-
create_table :commits, force: true do |t|
|
20
|
-
t.string :sha
|
21
|
-
t.string :author
|
22
|
-
t.date :author_date
|
23
|
-
end
|
24
|
-
|
25
|
-
create_table :file_changes, force: true do |t|
|
26
|
-
t.references :commit
|
27
|
-
t.string :pathname
|
28
|
-
t.integer :additions
|
29
|
-
t.integer :deletions
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
command.run("git log --no-merges --pretty=format:'%H%n%ad%n%ae' --numstat --since=1.years > .churned/hashes.txt")
|
34
|
-
|
35
|
-
IO.read('.churned/hashes.txt').split("\n\n").each do |description|
|
36
|
-
lines = description.split("\n")
|
37
|
-
|
38
|
-
sha = lines.shift
|
39
|
-
date = lines.shift
|
40
|
-
author = lines.shift
|
41
|
-
commit = Commit.new(sha: sha, author_date: date, author: author)
|
42
|
-
|
43
|
-
lines.each do |numstat|
|
44
|
-
additions, deletions, pathname = numstat.split("\t")
|
45
|
-
commit.file_changes.build(additions: additions, deletions: deletions, pathname: pathname)
|
46
|
-
end
|
47
|
-
|
48
|
-
commit.save
|
49
|
-
end
|
12
|
+
def execute(filename = ".churned/hashes.txt", input: $stdin, output: $stdout)
|
13
|
+
db.create
|
14
|
+
command.run("git log --no-merges --pretty=format:'%H%n%ad%n%ae' --numstat --since=1.years > #{filename}")
|
15
|
+
db.load(filename)
|
50
16
|
end
|
51
17
|
end
|
52
18
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
@@ -0,0 +1 @@
|
|
1
|
+
#
|
data/lib/churned/version.rb
CHANGED
data/lib/churned.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
require "sqlite3"
|
1
|
+
require_relative "../config/database"
|
3
2
|
require "churned/version"
|
4
3
|
require "churned/cli"
|
5
4
|
|
6
|
-
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ".churned/database")
|
7
|
-
|
8
5
|
module Churned
|
9
6
|
class Commit < ActiveRecord::Base
|
10
7
|
has_many :file_changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: churned
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Barret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -125,17 +125,24 @@ files:
|
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
127
127
|
- bin/console
|
128
|
+
- bin/debug
|
128
129
|
- bin/setup
|
129
130
|
- churned.gemspec
|
131
|
+
- config/database.rb
|
130
132
|
- exe/churned
|
131
133
|
- lib/churned.rb
|
132
134
|
- lib/churned/cli.rb
|
133
135
|
- lib/churned/command.rb
|
134
136
|
- lib/churned/commands/.gitkeep
|
135
137
|
- lib/churned/commands/console.rb
|
138
|
+
- lib/churned/commands/db.rb
|
139
|
+
- lib/churned/commands/db/create.rb
|
140
|
+
- lib/churned/commands/db/load.rb
|
136
141
|
- lib/churned/commands/install.rb
|
137
142
|
- lib/churned/templates/.gitkeep
|
138
143
|
- lib/churned/templates/console/.gitkeep
|
144
|
+
- lib/churned/templates/db/create/.gitkeep
|
145
|
+
- lib/churned/templates/db/load/.gitkeep
|
139
146
|
- lib/churned/templates/install/.gitkeep
|
140
147
|
- lib/churned/version.rb
|
141
148
|
homepage: https://github.com/AlexB52/churned
|