repos_report 2.0.2 → 2.0.3
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/lib/repos_report.rb +19 -16
- data/lib/repos_report/repo.rb +16 -27
- data/lib/repos_report/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc3663c3fa77e055d3842b6cb0e8c8b013dfc276
|
4
|
+
data.tar.gz: 33357575db4cf1081f7603349271b4c63c88c19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1229ff946f8684703910b0a3cb6a875ef3701e656871530f67eef41ece5bd32c65d4cccecfc0e8334d8492742bf5b12db627edd8276e7da8deec92b35e910d8
|
7
|
+
data.tar.gz: 5e26abfc0206fadd5f9aa413595118d111b9155b62dddbd7f1c2eb7685d20c55c1246e3b71172d91eb6b6e1717cc09902e9fe7ceaa8286471f91e532fcf1923f
|
data/lib/repos_report.rb
CHANGED
@@ -3,19 +3,10 @@ require_relative 'repos_report/repo_finder'
|
|
3
3
|
module ReposReport
|
4
4
|
class << self
|
5
5
|
def print_status_of_projects_under(directory)
|
6
|
-
|
7
6
|
repos = RepoFinder.repos_in_or_below(directory)
|
8
7
|
|
9
8
|
if repos.any?
|
10
|
-
|
11
|
-
|
12
|
-
puts
|
13
|
-
|
14
|
-
repos.each do |r|
|
15
|
-
puts r.concise_status(padding_amount)
|
16
|
-
end
|
17
|
-
|
18
|
-
puts
|
9
|
+
print_statuses_of(repos)
|
19
10
|
else
|
20
11
|
puts "No repos found in this directory."
|
21
12
|
end
|
@@ -24,21 +15,33 @@ module ReposReport
|
|
24
15
|
def list_all_repos(directory)
|
25
16
|
repos = RepoFinder.repos_in_or_below(directory)
|
26
17
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
newline_pad_output do
|
19
|
+
repos.each do |repo|
|
20
|
+
puts repo.directory
|
21
|
+
end
|
31
22
|
end
|
32
|
-
|
33
|
-
puts
|
34
23
|
end
|
35
24
|
|
36
25
|
private
|
37
26
|
|
27
|
+
def print_statuses_of(repos)
|
28
|
+
padding_amount = whitespace_padding_for(repos)
|
29
|
+
|
30
|
+
newline_pad_output do
|
31
|
+
repos.each do |r|
|
32
|
+
puts r.concise_status(padding_amount)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
38
37
|
def whitespace_padding_for(repos)
|
39
38
|
longest_repo_project_name(repos) + 3
|
40
39
|
end
|
41
40
|
|
41
|
+
def newline_pad_output
|
42
|
+
puts; yield; puts
|
43
|
+
end
|
44
|
+
|
42
45
|
def longest_repo_project_name(array_of_repos)
|
43
46
|
array_of_repos.map(&:project_name_length).max
|
44
47
|
end
|
data/lib/repos_report/repo.rb
CHANGED
@@ -12,6 +12,8 @@ class Repo
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def concise_status(whitespace_padding)
|
15
|
+
set_git_variables # Not needed unless this method is run
|
16
|
+
|
15
17
|
if issues.any?
|
16
18
|
message_with_issues(whitespace_padding).red
|
17
19
|
else
|
@@ -27,6 +29,12 @@ class Repo
|
|
27
29
|
@directory.split("/").last
|
28
30
|
end
|
29
31
|
|
32
|
+
def set_git_variables
|
33
|
+
@origin_master_output ||= `cd #{@directory}; git for-each-ref --format="%(upstream:track) %(upstream:short)" | grep origin/master`
|
34
|
+
@git_remote_output ||= `cd #{@directory}; git remote`
|
35
|
+
@git_status_output ||= `cd #{@directory}; git status`
|
36
|
+
end
|
37
|
+
|
30
38
|
def message_with_issues(whitespace_padding)
|
31
39
|
project_name + whitespace_padding(whitespace_padding) + issues.join(', ')
|
32
40
|
end
|
@@ -40,34 +48,15 @@ class Repo
|
|
40
48
|
end
|
41
49
|
|
42
50
|
def issues
|
43
|
-
[
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
issue_array = []
|
52
|
+
issue_array << 'UNPUSHED COMMITS' if @origin_master_output.include? 'ahead'
|
53
|
+
issue_array << 'UNPULLED COMMITS' if @origin_master_output.include? 'behind'
|
54
|
+
issue_array << 'NO REMOTE ORIGIN' unless @git_remote_output.include? 'origin'
|
55
|
+
issue_array << 'UNCOMMITTED CHANGES' if @git_status_output =~ uncommitted_changes_regex
|
56
|
+
issue_array
|
47
57
|
end
|
48
58
|
|
49
|
-
def
|
50
|
-
|
51
|
-
ahead_or_behind = `cd #{@directory}; git for-each-ref --format="%(upstream:track) %(upstream:short)" | grep origin/master`
|
52
|
-
|
53
|
-
if ahead_or_behind.include? 'ahead'
|
54
|
-
'UNPUSHED COMMITS'
|
55
|
-
elsif ahead_or_behind.include? 'behind'
|
56
|
-
'UNPULLED COMMITS'
|
57
|
-
elsif `cd #{@directory}; git remote`.include? 'origin'
|
58
|
-
nil
|
59
|
-
else
|
60
|
-
'NO REMOTE ORIGIN'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def uncommitted_changes
|
65
|
-
changes = false
|
66
|
-
|
67
|
-
changes = true if `cd #{@directory}; git status | grep 'Changes not staged for commit'`.length > 0
|
68
|
-
changes = true if `cd #{@directory}; git status | grep 'Changes to be committed'`.length > 0
|
69
|
-
changes = true if `cd #{@directory}; git status | grep 'Untracked files'`.length > 0
|
70
|
-
|
71
|
-
changes ? "UNCOMMITTED CHANGES" : nil
|
59
|
+
def uncommitted_changes_regex
|
60
|
+
/(Changes not staged for commit)|(Changes to be committed)|(Untracked files)/
|
72
61
|
end
|
73
62
|
end
|
data/lib/repos_report/version.rb
CHANGED