Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
sync-all 31.93 KiB
#!/usr/bin/perl -w

use strict;
use Cwd;
use English;

$| = 1; # autoflush stdout after each print, to avoid output after die

my $initial_working_directory;

my $defaultrepo;
my @packages;
my $verbose = 2;
my $try_to_resume = 0;
my $ignore_failure = 0;
my $checked_out_flag = 0; # NOT the opposite of bare_flag (describes remote repo state)
my $get_mode;
my $bare_flag = ""; # NOT the opposite of checked_out_flag (describes local repo state)

my %tags;

my $GITHUB = qr!(?:git@|git://|https://|http://)github.com!;

sub inDir {
    my $dir = shift;
    my $code = shift;

    if ($dir ne '.') {
        chdir($dir);
    }

    my $result = &$code();

    if ($dir ne '.') {
        chdir($initial_working_directory);
    }
    return $result;
}

sub parsePackages {
    my @repos;
    my $lineNum;

    open IN, "< packages.conf"
        or open IN, "< packages" # clashes with packages directory when using --bare
        or die "Can't open packages file (or packages.conf)";
    @repos = <IN>;
    close IN;

    @packages = ();
    $lineNum = 0;
    foreach (@repos) {
        chomp;
        $lineNum++;
        if (/^([^# ]+) +([^ ]+) +([^ ]+) +([^ ]+)$/) {
            my %line;
            $line{"localpath"}  = $1;
            $line{"tag"}        = $2;
            $line{"remotepath"} = $3;
            $line{"upstreamurl"}= $4;
            push @packages, \%line;

            $tags{$2} = 0;
        }
        elsif (! /^(#.*)?$/) {
            die "Bad content on line $lineNum of packages file: $_";
        }
    }
}