<commit_before>#!/usr/bin/env perl

use strict;

use Cwd;

die "Must specify location of source git repo"
    if ($#ARGV < 0);

sub doit {
    my ($cmd) = shift;

    my $rc;
    my $outfile = "/tmp/github-send-email-tmp.$$";
    unlink($outfile);
    $rc = system("$cmd >$outfile 2>&1");
    if (0 != $rc) {
        print "Command failed: $cmd
Output:\n";
        open(IN, $outfile);
        print $_
            while (<IN>);
        close(IN);
        die "Aborting";
    }
    unlink($outfile);
}

foreach my $src_repo (@ARGV) {
    die "Specified location of source git repo is invalid"
        if (! -d $src_repo);
    chdir($src_repo);
    die "Could not chdir to $src_repo"
        if (getcwd() != $src_repo);

    doit("/u/mpiteam/git/local/bin/git fetch");
    doit("/u/mpiteam/git/local/bin/git push email");
}
<commit_msg>If a git command fails, also print the repo in the error message<commit_after>#!/usr/bin/env perl

use strict;

use Cwd;

die "Must specify location of source git repo"
    if ($#ARGV < 0);

sub doit {
    my ($cmd, $repo) = @_;

    my $rc;
    my $outfile = "/tmp/github-send-email-tmp.$$";
    unlink($outfile);
    $rc = system("$cmd >$outfile 2>&1");
    if (0 != $rc) {
        print "Command failed:

Command: $cmd
Repo:    $repo
Output:\n";
        open(IN, $outfile);
        print $_
            while (<IN>);
        close(IN);
        die "Aborting";
    }
    unlink($outfile);
}

foreach my $src_repo (@ARGV) {
    die "Specified location of source git repo is invalid"
        if (! -d $src_repo);
    chdir($src_repo);
    die "Could not chdir to $src_repo"
        if (getcwd() != $src_repo);

    doit("/u/mpiteam/git/local/bin/git fetch", $src_repo);
    doit("/u/mpiteam/git/local/bin/git push email", $src_repo);
}

{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.004519774011299435, 'mean_word_length': 2.41233140655106, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7306150', 'n_tokens_mistral': 657, 'n_tokens_neox': 645, 'n_words': 177}