App-IsGitSynced

 view release on metacpan or  search on metacpan

bin/is_git_synced  view on Meta::CPAN

    my ($path) = @_;

    my $output = `cd $path; git branch`;
    my @branches = map { s/..(.*)/$1/; $_; } split(/\n/, $output);

    my $has_divergences_with_origin;
    foreach my $branch (@branches) {
        next if $branch eq '(no branch)';
        next if $branch =~ /(detached .*)/;

        my $local = `cd $path; git rev-parse --verify $branch 2>&1`;
        my $origin = `cd $path; git rev-parse --verify origin/$branch 2>&1`;

        $has_divergences_with_origin = $TRUE if $local ne $origin;
    }

    if (not $has_divergences_with_origin) {
        return $STATUSES{success};
    } else {
        return (
            $STATUSES{fail},
            "path '$path' has some divergences with remote 'origin'",



( run in 0.295 second using v1.01-cache-2.11-cpan-73692580452 )