repokeeper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/GPLv3 +674 -0
- data/LICENSE +14 -0
- data/README.md +184 -0
- data/bin/repokeeper +7 -0
- data/config/default.yml +13 -0
- data/lib/repokeeper/analyzers/analyzer.rb +26 -0
- data/lib/repokeeper/analyzers/analyzers_set.rb +11 -0
- data/lib/repokeeper/analyzers/branches/local_branches_count.rb +20 -0
- data/lib/repokeeper/analyzers/branches/remote_branches_count.rb +20 -0
- data/lib/repokeeper/analyzers/commits/merge_commits.rb +11 -0
- data/lib/repokeeper/analyzers/commits/short_commit_message.rb +26 -0
- data/lib/repokeeper/analyzers/commits/similar_commits.rb +44 -0
- data/lib/repokeeper/analyzers/mixins/branches_analyzer.rb +13 -0
- data/lib/repokeeper/analyzers/mixins/branches_count.rb +22 -0
- data/lib/repokeeper/analyzers/mixins/commits_analyzer.rb +19 -0
- data/lib/repokeeper/analyzers.rb +10 -0
- data/lib/repokeeper/cli.rb +62 -0
- data/lib/repokeeper/config.rb +43 -0
- data/lib/repokeeper/offenses/branches_offense.rb +8 -0
- data/lib/repokeeper/offenses/commit_offense.rb +8 -0
- data/lib/repokeeper/repo_analyzer.rb +68 -0
- data/lib/repokeeper/repo_proxy.rb +58 -0
- data/lib/repokeeper/rev_parser.rb +22 -0
- data/lib/repokeeper/simple_text_formatter.rb +64 -0
- data/lib/repokeeper/utils.rb +10 -0
- data/lib/repokeeper/version.rb +3 -0
- data/lib/repokeeper.rb +11 -0
- metadata +130 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'rugged'
|
2
|
+
require 'delegate'
|
3
|
+
|
4
|
+
module Repokeeper
|
5
|
+
class RepoProxy
|
6
|
+
# Walks specified range
|
7
|
+
class BoundedWalker < SimpleDelegator
|
8
|
+
def initialize(walker, rev_range)
|
9
|
+
super(walker)
|
10
|
+
@rev_range = rev_range
|
11
|
+
configure_walker
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def configure_walker
|
17
|
+
sorting(Rugged::SORT_TOPO)
|
18
|
+
push(@rev_range.end_rev)
|
19
|
+
hide(@rev_range.start_rev) if @rev_range.start_rev
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(repo_path)
|
24
|
+
@repo = open_repo(repo_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
def commits(rev_range = nil)
|
28
|
+
rev_range ||= RevParser::RevRange.new
|
29
|
+
rev_range = check_rev_range(rev_range)
|
30
|
+
create_walker(rev_range).to_a
|
31
|
+
end
|
32
|
+
|
33
|
+
def local_branches
|
34
|
+
@repo.branches.each_name(:local).sort
|
35
|
+
end
|
36
|
+
|
37
|
+
def remote_branches
|
38
|
+
@repo.branches.each_name(:remote).sort
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def check_rev_range(rev_range)
|
44
|
+
end_rev = rev_range.end_rev || @repo.head.name
|
45
|
+
start_rev = rev_range.start_rev
|
46
|
+
RevParser::RevRange.new(end_rev, start_rev)
|
47
|
+
end
|
48
|
+
|
49
|
+
def open_repo(repo_path)
|
50
|
+
Rugged::Repository.discover(repo_path)
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_walker(rev_range)
|
54
|
+
walker = Rugged::Walker.new(@repo)
|
55
|
+
BoundedWalker.new(walker, rev_range)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Repokeeper
|
2
|
+
# Parser for revision or revision range
|
3
|
+
class RevParser
|
4
|
+
RevRange = Struct.new(:end_rev, :start_rev)
|
5
|
+
|
6
|
+
attr_reader :range
|
7
|
+
|
8
|
+
def initialize(revisions = nil)
|
9
|
+
@revisions = revisions || ''
|
10
|
+
end
|
11
|
+
|
12
|
+
def parse
|
13
|
+
@range = RevRange.new(*parse_revs)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def parse_revs
|
19
|
+
@revisions.split('..').reverse
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Repokeeper
|
2
|
+
class SimpleTextFormatter
|
3
|
+
def initialize(out_stream = $stdout)
|
4
|
+
@out_stream = out_stream
|
5
|
+
end
|
6
|
+
|
7
|
+
def started
|
8
|
+
@commits = Hash.new { |h, k| h[k] = [] }
|
9
|
+
@branches = Hash.new { |h, k| h[k] = [] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def commits_analyzer_results(analyzer_name, offenses)
|
13
|
+
@commits[analyzer_name].concat(Array(offenses))
|
14
|
+
end
|
15
|
+
|
16
|
+
def branches_analyzer_results(analyzer_name, offenses)
|
17
|
+
@branches[analyzer_name].concat(Array(offenses))
|
18
|
+
end
|
19
|
+
|
20
|
+
def finished
|
21
|
+
write_results(@commits, :commit_offense_message)
|
22
|
+
write_results(@branches, :branch_offense_message)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def write_results(collection, write_offense_method)
|
28
|
+
collection.keys.sort.each do |analyzer_name|
|
29
|
+
offenses = collection[analyzer_name].compact
|
30
|
+
write_analyzer_results(analyzer_name, offenses, write_offense_method)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def write_analyzer_results(analyzer_name, offenses, write_offense_method)
|
35
|
+
@out_stream.puts "=== #{analyzer_name} ==="
|
36
|
+
|
37
|
+
if offenses.empty?
|
38
|
+
@out_stream.puts 'No issues were found'
|
39
|
+
else
|
40
|
+
offenses.each do |offense|
|
41
|
+
@out_stream.puts send(write_offense_method, offense)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
@out_stream.puts
|
46
|
+
end
|
47
|
+
|
48
|
+
def commit_offense_message(offense)
|
49
|
+
error_message = offense.message
|
50
|
+
commit = offense.commit
|
51
|
+
id = commit.oid
|
52
|
+
author = commit.author[:name]
|
53
|
+
|
54
|
+
"#{id} by #{author}. #{error_message}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def branch_offense_message(offense)
|
58
|
+
error_message = offense.message
|
59
|
+
branches = offense.branches.join(', ')
|
60
|
+
|
61
|
+
"#{error_message} - #{branches}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/repokeeper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'repokeeper/version'
|
2
|
+
require 'repokeeper/config'
|
3
|
+
require 'repokeeper/cli'
|
4
|
+
require 'repokeeper/rev_parser'
|
5
|
+
require 'repokeeper/utils'
|
6
|
+
require 'repokeeper/repo_proxy'
|
7
|
+
require 'repokeeper/repo_analyzer'
|
8
|
+
require 'repokeeper/simple_text_formatter'
|
9
|
+
require 'repokeeper/analyzers'
|
10
|
+
require 'repokeeper/offenses/commit_offense'
|
11
|
+
require 'repokeeper/offenses/branches_offense'
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: repokeeper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anatoliy Plastinin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rugged
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.21'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.21'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: methadone
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: levenshtein-ffi
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
69
|
+
description: |
|
70
|
+
Repokeeper is a tool for analysis of git repositotories
|
71
|
+
for common flaws in a workflow.
|
72
|
+
email:
|
73
|
+
- hello@antlypls.com
|
74
|
+
executables:
|
75
|
+
- repokeeper
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- GPLv3
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- bin/repokeeper
|
83
|
+
- config/default.yml
|
84
|
+
- lib/repokeeper.rb
|
85
|
+
- lib/repokeeper/analyzers.rb
|
86
|
+
- lib/repokeeper/analyzers/analyzer.rb
|
87
|
+
- lib/repokeeper/analyzers/analyzers_set.rb
|
88
|
+
- lib/repokeeper/analyzers/branches/local_branches_count.rb
|
89
|
+
- lib/repokeeper/analyzers/branches/remote_branches_count.rb
|
90
|
+
- lib/repokeeper/analyzers/commits/merge_commits.rb
|
91
|
+
- lib/repokeeper/analyzers/commits/short_commit_message.rb
|
92
|
+
- lib/repokeeper/analyzers/commits/similar_commits.rb
|
93
|
+
- lib/repokeeper/analyzers/mixins/branches_analyzer.rb
|
94
|
+
- lib/repokeeper/analyzers/mixins/branches_count.rb
|
95
|
+
- lib/repokeeper/analyzers/mixins/commits_analyzer.rb
|
96
|
+
- lib/repokeeper/cli.rb
|
97
|
+
- lib/repokeeper/config.rb
|
98
|
+
- lib/repokeeper/offenses/branches_offense.rb
|
99
|
+
- lib/repokeeper/offenses/commit_offense.rb
|
100
|
+
- lib/repokeeper/repo_analyzer.rb
|
101
|
+
- lib/repokeeper/repo_proxy.rb
|
102
|
+
- lib/repokeeper/rev_parser.rb
|
103
|
+
- lib/repokeeper/simple_text_formatter.rb
|
104
|
+
- lib/repokeeper/utils.rb
|
105
|
+
- lib/repokeeper/version.rb
|
106
|
+
homepage: https://github.com/antlypls/repokeeper
|
107
|
+
licenses:
|
108
|
+
- GPLv3
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.4.1
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Repokeeper - git repo analysis tool
|
130
|
+
test_files: []
|