-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTask-git
executable file
·41 lines (34 loc) · 1.43 KB
/
Task-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
#!/usr/local/bin/perl
## automate routine git archive updates, and push changes to remote
# David H. 2018-06-01
chdir "$ENV{HOME}/perl6/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_task = 'update of task';
$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` =~ /(perl6|raku) script text executable/)
or
$new =~ /^(bin|docs|gh-issues)/;
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"] }
elsif ($modified =~ m#ref/#) { system qq[$git add $modified; $git commit -m "$msg_ref"] }
elsif ($modified =~ /task.txt/) { system qq[$git add $modified; $git commit -m "$msg_stat"] }
else { system qq[$git add $modified; $git commit -m "$msg_task $modified"] }
}
system "$git push origin master";