-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask5-git
executable file
·43 lines (36 loc) · 1.71 KB
/
Task5-git
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
#!/usr/local/bin/perl
## automate routine git archive updates, and push changes to remote
# David H. 2018-06-01
chdir "$ENV{HOME}/perl5/Rosetta-Code";
# at this time, allow automatic commits only from Mac-Pro
exit unless -t or `uname -a` =~ /Mac-Pro/;
$git = `which git`; chomp $git; die unless $git;
$msg_bin = 'update of tooling';
$msg_task = 'update of task';
$msg_meta = 'update of meta-info';
#$msg_prog = 'update of control program';
$msg_stat = 'daily update of task status';
$msg_new = 'initial commit of task';
$msg_ref = 'update of reference data';
# always commit from main branch
system "$git switch master";
# new tasks
for $new (`$git status | grep -v modified: | grep '^\t'`) {
chomp $new;
$new =~ s/^\t//;
next unless -X $new && `file $new` =~ /perl.*script text executable/;
#next unless -X $new && `file $new` =~ /perl (-Ilib )?script text executable/;
system qq[$git add $new; $git commit -m "$msg_new $new"];
}
# updated tasks and programs
for $modified (`$git status | grep modified:`) {
chomp $modified;
$modified =~ s/^.*:\s+//;
# if ($modified =~ m#^rc#) { system qq[$git add $modified; $git commit -m "$msg_prog $modified"] }
if ($modified =~ m#\bref/#) { system qq[$git add $modified; $git commit -m "$msg_ref"] }
elsif ($modified =~ m#\bbin/#) { system qq[$git add $modified; $git commit -m "$msg_bin"] }
elsif ($modified =~ /task.txt/) { system qq[$git add $modified; $git commit -m "$msg_stat"] }
elsif ($modified =~ /\bmeta\b/) { system qq[$git add $modified; $git commit -m "$msg_meta $modified"] }
else { system qq[$git add $modified; $git commit -m "$msg_task $modified"] }
}
system "$git push origin master";