-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitmess.pl
More file actions
45 lines (36 loc) · 869 Bytes
/
Copy pathgitmess.pl
File metadata and controls
45 lines (36 loc) · 869 Bytes
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
#!/usr/bin/env perl
use strict;
use warnings;
my %groups = (
add => [],
modified => [],
remove => [],
);
while (<STDIN>) {
chomp;
if (/^\s*new file:\s+(.+)/) {
push @{$groups{add}}, $1;
}
elsif (/^\s*modified:\s+(.+)/) {
push @{$groups{modified}}, $1;
}
elsif (/^\s*deleted:\s+(.+)/) {
push @{$groups{remove}}, $1;
}
}
my @messages;
for my $file (@{$groups{add}}) {
push @messages, "-m 'add: $file'";
}
for my $file (@{$groups{modified}}) {
push @messages, "-m 'modified: $file'";
}
for my $file (@{$groups{remove}}) {
push @messages, "-m 'remove: $file'";
}
if (@messages) {
print "\033[0mYour git commit message is ready\n";
print "\033[1;31m> \033[0;32mgit commit " . join(' ', @messages) . "\033[0m\n";
} else {
print "\033[1;31m[!] \033[0mNothing canged.\n";
}