This repository was archived by the owner on Sep 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitview.pl
More file actions
81 lines (68 loc) · 1.68 KB
/
Copy pathgitview.pl
File metadata and controls
81 lines (68 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
use strict;
use warnings;
use Term::ANSIColor;
my $cmd = `locate .git/HEAD`;
#my $cmd = `find / -wholename "*.git/HEAD" 2>/dev/null`;
my @gitMasterRepo = ();
my @gitOtherRepo = ();
foreach my $line (split /[\r\n]+/, $cmd) {
open(my $fh, '<', $line);
while(my $row = <$fh>)
{
chomp $row;
if($row =~ /^ref: refs\/heads\/master$/)
{
push @gitMasterRepo, $line;
}
else
{
push @gitOtherRepo, {'line' => $line, 'row' => $row};
}
}
close $fh;
}
for(my $i = 0; $i < scalar(@gitMasterRepo); $i++)
{
my $path = '';
if($gitMasterRepo[$i] =~ /^(\/.+)\.git\/HEAD$/)
{
$path = $1;
print $path."\n";
}
$cmd = `cd $path && git status`;
foreach my $gitStatus (split /[\r\n]+/, $cmd) {
if($gitStatus =~ m/(modified|added|deleted|renamed|copied):/)
{
print color('blue');
print $gitStatus."\n";
print color('reset');
}
}
}
for(my $i = 0; $i < scalar(@gitOtherRepo); $i++)
{
my $branch;
if($gitOtherRepo[$i]->{'row'} =~ /^ref: refs\/heads\/(.+)$/)
{
$branch = $1;
}
my $path = '';
if($gitOtherRepo[$i]->{'line'} =~ /^(\/.+)\.git\/HEAD$/)
{
$path = $1;
print $path;
print color('green');
print ' GIT['.$branch."]\n";
print color('reset');
}
$cmd = `cd $path && git status`;
foreach my $gitStatus (split /[\r\n]+/, $cmd) {
if($gitStatus =~ m/(modified|added|deleted|renamed|copied):/)
{
print color('blue');
print $gitStatus."\n";
print color('reset');
}
}
}