summaryrefslogtreecommitdiff
path: root/bin/src-register-all
blob: 0c993097362eccdc197f99dc5ab2877debba1796 (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
#!/usr/bin/perl

# Add new all new git/hg repos in ~/src to ~/src/.mrconfig

use strict;
use warnings;
use File::Basename;
use File::Grep "fgrep";
use File::chdir;

# TODO should recurse into arbitarary subdirectories of ~/src

foreach my $f ( glob "$ENV{'HOME'}/src/*" ) {
    my $short = basename($f);
    next unless ( -d "$f/.git" || -d "$f/.hg" );
    unless ( (fgrep { /^\[$short\]$/ }
              "$ENV{'HOME'}/src/.mrconfig")
             || (fgrep { /^\[\$HOME\/src\/$short\]$/ }
                 "$ENV{'HOME'}/.mrconfig") ) {
        local $CWD = $f;
        system "mr register >/dev/null";
        die "failed to register ~/src/$short" unless ($? >> 8 == 0);
    }
}