git-health-check 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/git-health-check/cli/git_health_check_command.rb +11 -10
- data/lib/git-health-check/cli/help_command.rb +0 -4
- data/lib/git-health-check/cli/options.rb +22 -4
- data/lib/git-health-check/git_lib.rb +0 -25
- data/lib/git-health-check/history.rb +4 -5
- data/lib/git-health-check/packfile.rb +2 -3
- data/lib/git-health-check/report.rb +3 -3
- data/lib/git-health-check/version.rb +1 -1
- data/lib/git-health-check/working_copy.rb +5 -5
- metadata +2 -2
@@ -5,20 +5,21 @@ module GitHealthCheck
|
|
5
5
|
|
6
6
|
class GitHealthCheckCommand
|
7
7
|
|
8
|
-
def initialize(parser,
|
9
|
-
@
|
8
|
+
def initialize(parser, options)
|
9
|
+
@options = options
|
10
10
|
@parser = parser
|
11
|
-
@
|
11
|
+
@threshold = options[:threshold]
|
12
|
+
@limit = options[:limit]
|
13
|
+
@history = GitHealthCheck::History.new options
|
14
|
+
@working_copy = GitHealthCheck::WorkingCopy.new options
|
15
|
+
@packfile = GitHealthCheck::Packfile.new
|
12
16
|
end
|
13
17
|
|
14
18
|
def execute(view)
|
15
|
-
|
16
|
-
working_copy = GitHealthCheck::WorkingCopy.new @repository
|
17
|
-
packfile = GitHealthCheck::Packfile.new(@repository)
|
18
|
-
packfile.packfile_stats
|
19
|
+
@packfile.packfile_stats
|
19
20
|
|
20
|
-
working_copy_output = working_copy.find_in_working_copy
|
21
|
-
history_output = history.search
|
21
|
+
working_copy_output = @working_copy.find_in_working_copy
|
22
|
+
history_output = @history.search
|
22
23
|
|
23
24
|
working_copy_report = Table('object sha', 'size (MB)', 'path')
|
24
25
|
history_report = Table('object sha', 'size (MB)', 'path', 'commit details', 'author')
|
@@ -26,7 +27,7 @@ module GitHealthCheck
|
|
26
27
|
working_copy_output.each { |sha, size, path| working_copy_report << [sha, size, path] }
|
27
28
|
history_output.each { |sha, size, path, where, who| history_report << [sha, size, path, where, who] }
|
28
29
|
|
29
|
-
report = GitHealthCheck::Report.new(working_copy_report.to_html, history_report.to_html, packfile)
|
30
|
+
report = GitHealthCheck::Report.new(working_copy_report.to_html, history_report.to_html, @packfile, @options)
|
30
31
|
report.create
|
31
32
|
|
32
33
|
view.report_success
|
@@ -7,6 +7,11 @@ module GitHealthCheck
|
|
7
7
|
|
8
8
|
def initialize(argv)
|
9
9
|
@argv = argv
|
10
|
+
@options = {
|
11
|
+
:threshold => 0.5,
|
12
|
+
:limit => 10,
|
13
|
+
:repository => Dir.pwd
|
14
|
+
}
|
10
15
|
@parser = OptionParser.new
|
11
16
|
@command_class = GitHealthCheckCommand
|
12
17
|
set_parser_options
|
@@ -21,7 +26,10 @@ Output metrics for your Git repository.
|
|
21
26
|
Examples:
|
22
27
|
ghc
|
23
28
|
ghc -t 10
|
24
|
-
ghc
|
29
|
+
ghc --threshold 0.2
|
30
|
+
ghc -l 20
|
31
|
+
ghc --threshold 5 --limit 20
|
32
|
+
ghc -r projects/my_repo -t 10 -l 30
|
25
33
|
|
26
34
|
EOB
|
27
35
|
end
|
@@ -35,14 +43,24 @@ EOB
|
|
35
43
|
|
36
44
|
@parser.on('-h', '--help', 'Displays this help message') { @command_class = HelpCommand }
|
37
45
|
|
38
|
-
@parser.on('-t', '--threshold THRESHOLD', Float, 'Specify history
|
39
|
-
@threshold = n
|
46
|
+
@parser.on('-t', '--threshold THRESHOLD', Float, 'Specify minimum history threshold in MB (default 0.5)') do |n|
|
47
|
+
@options[:threshold] = n
|
48
|
+
end
|
49
|
+
|
50
|
+
@parser.on('-l', '--limit LIMIT', Integer, 'Specify working copy results limit (default 10)') do |n|
|
51
|
+
@options[:limit] = n
|
52
|
+
end
|
53
|
+
|
54
|
+
@parser.on('-r', '--repository REPOSITORY', String,
|
55
|
+
'Specify the repository (current directory by default)') do |repo|
|
56
|
+
Dir.chdir repo # handles relative directories
|
57
|
+
@options[:repository] = Dir.pwd
|
40
58
|
end
|
41
59
|
end
|
42
60
|
|
43
61
|
def parse
|
44
62
|
@parser.parse!(@argv)
|
45
|
-
@
|
63
|
+
@command_class.new(@parser, @options)
|
46
64
|
end
|
47
65
|
|
48
66
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module GitHealthCheck
|
2
2
|
class GitLib
|
3
3
|
|
4
|
-
def initialize(repository_path)
|
5
|
-
Dir.chdir repository_path
|
6
|
-
end
|
7
|
-
|
8
4
|
def get_commit_author(commit_sha)
|
9
5
|
`git log #{commit_sha} -n 1 | grep Author | cut -f 2- -d ' '`.chomp
|
10
6
|
end
|
@@ -13,27 +9,6 @@ module GitHealthCheck
|
|
13
9
|
`git show -s #{commit_sha} --format='%h: %cr'`.chomp
|
14
10
|
end
|
15
11
|
|
16
|
-
def get_pack_number
|
17
|
-
`ls .git/objects/pack/pack-*.idx 2> /dev/null | wc -l`.to_i
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_status
|
21
|
-
`git status`
|
22
|
-
end
|
23
|
-
|
24
|
-
def filesystem_check
|
25
|
-
`git fsck --full --strict`
|
26
|
-
end
|
27
|
-
|
28
|
-
def garbage_collection
|
29
|
-
`git gc`
|
30
|
-
end
|
31
|
-
|
32
|
-
def repack
|
33
|
-
`git repack -a -d -f --depth=250 --window=250` # better than gc --aggressive
|
34
|
-
# http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/
|
35
|
-
end
|
36
|
-
|
37
12
|
def count_objects
|
38
13
|
`git count-objects -v`
|
39
14
|
end
|
@@ -7,11 +7,10 @@ module GitHealthCheck
|
|
7
7
|
|
8
8
|
MEGABYTE = 1024 ** 2
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@repository = repository
|
12
|
-
@bytes_threshold = threshold.to_f * MEGABYTE
|
13
|
-
|
14
|
-
@git_lib = GitHealthCheck::GitLib.new repository
|
10
|
+
def initialize(options)
|
11
|
+
@repository = options[:repository]
|
12
|
+
@bytes_threshold = options[:threshold].to_f * MEGABYTE
|
13
|
+
@git_lib = GitHealthCheck::GitLib.new
|
15
14
|
end
|
16
15
|
|
17
16
|
def search
|
@@ -9,9 +9,8 @@ module GitHealthCheck
|
|
9
9
|
attr_reader :prune_packable
|
10
10
|
attr_reader :garbage
|
11
11
|
|
12
|
-
def initialize
|
13
|
-
@
|
14
|
-
@git_lib = GitHealthCheck::GitLib.new repository
|
12
|
+
def initialize
|
13
|
+
@git_lib = GitHealthCheck::GitLib.new
|
15
14
|
end
|
16
15
|
|
17
16
|
def packfile_stats
|
@@ -4,12 +4,12 @@ module GitHealthCheck
|
|
4
4
|
|
5
5
|
class Report
|
6
6
|
|
7
|
-
def initialize(working_copy, history, packfile)
|
7
|
+
def initialize(working_copy, history, packfile, options)
|
8
8
|
@working_copy = working_copy
|
9
9
|
@history = history
|
10
10
|
@packfile = packfile
|
11
|
-
@
|
12
|
-
@
|
11
|
+
@repository = options[:repository]
|
12
|
+
@report_directory = @repository + '/healthcheck'
|
13
13
|
end
|
14
14
|
|
15
15
|
def get_binding
|
@@ -2,13 +2,13 @@ module GitHealthCheck
|
|
2
2
|
|
3
3
|
class WorkingCopy
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@git_lib = GitHealthCheck::GitLib.new
|
5
|
+
def initialize(options)
|
6
|
+
@limit = options[:limit]
|
7
|
+
@git_lib = GitHealthCheck::GitLib.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def find_in_working_copy
|
11
|
-
largest_files = @git_lib.get_largest_files
|
10
|
+
def find_in_working_copy
|
11
|
+
largest_files = @git_lib.get_largest_files @limit
|
12
12
|
largest_files = largest_files.split "\n"
|
13
13
|
|
14
14
|
files = []
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-health-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruport
|