blob: d5baf2c189ff2180c51c3c1f3df99b687beeafcf (
plain)
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
|
#!/usr/bin/perl
use strict;
use warnings;
use File::Path qw(make_path);
use constant VCX_DIR => '.vcx';
use constant BASE_DIR => VCX_DIR . '/bse';
use constant OBJ_DIR => VCX_DIR . '/obj';
use constant TMP_DIR => VCX_DIR . '/tmp';
my $cmd = $ARGV[0] // '';
if ($cmd eq 'init') {
init_repo();
} elsif ($cmd eq 'status') {
run_status();
} else {
print "Usage: $0 [init|status]\n";
exit 1;
}
sub init_repo {
my @dirs = (OBJ_DIR, BASE_DIR, TMP_DIR);
foreach my $dir (@dirs) {
if (!-d $dir) {
make_path($dir);
print "Created: $dir\n";
}
}
print "Repository ready\n";
}
sub run_status {
my $diff_cmd = "diff -x " . VCX_DIR . " -rq " . BASE_DIR . " .";
$diff_cmd .= " -X .vcxignore" if -e ".vcxignore";
my @output = `$diff_cmd`;
foreach my $line (@output) {
chomp $line;
# Format output
if ($line =~ /^Only in \Q@{[BASE_DIR]}\E: (.+)$/) {
print "[D] $1\n";
} elsif ($line =~ /^Only in \.: (.+)$/) {
print "[N] $1\n";
} elsif ($line =~ /^Files \Q@{[BASE_DIR]}\E\/(.+) and \.\/(.+) differ$/) {
print "[M] $1\n";
}
}
}
|