<commit_before>#!/usr/bin/perl -w

# ====================================================================
# commit-email.pl: send a commit email for commit REVISION in
# repository REPOS to some email addresses.
#
# Usage: commit-email.pl REPOS REVISION [OPTIONS] [EMAIL-ADDR ...]
#
# Options:
#    -h hostname       :  Hostname to append to author for 'From:'
#    -l logfile        :  File to while mail contents should be 
#                         appended
#    -s subject_prefix :  Subject line prefix
#    
# ====================================================================
# Copyright (c) 2000-2001 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================

use strict;

######################################################################
#  CONFIGURATION SECTION
######################################################################

# sendmail path
my $sendmail = "/usr/sbin/sendmail";

# svnlook path
my $svnlook = "/usr/local/bin/svnlook";

######################################################################

# get the REPOS from the arguments
my $repos = shift @ARGV;

# get the REVISION from the arguments
my $rev = shift @ARGV;

# initialize the EMAIL_ADDRS to the remaining arguments
my @email_addrs = @ARGV;

# now, we see if there are any options included in the argument list
my $logfile = '';
my $hostname = '';
my $subject_prefix = '';
while (scalar @email_addrs)
{
    my $option = shift @email_addrs;
    if ($option eq '-h')
    {
        # found a hostname option
        $hostname = shift @email_addrs;
    }
    elsif ($option eq '-l')
    {
        # found a logfile option
        $logfile = shift @email_addrs;
    }
    elsif ($option eq '-s')
    {
        # found a subject prefix option
        $subject_prefix = shift @email_addrs;
    }
    else
    {
        # not an option, put it back!
        unshift @email_addrs, ($option);
        last;
    }
}

my @svnlooklines = ();
my @output = ();

# get the auther, date, and log from svnlook
open (INPUT, "$svnlook $repos rev $rev info |") 
    or die ("Error running svnlook (info)");
@svnlooklines = <INPUT>;
close (INPUT);
my $author = shift @svnlooklines;
my $date = shift @svnlooklines;
shift @svnlooklines;
my @log = @svnlooklines;
chomp $author;
chomp $date;

# figure out what directories have changed (using svnlook)
open (INPUT, "$svnlook $repos rev $rev dirs-changed |")
    or die ("Error running svnlook (changed)");
my @dirschanged = <INPUT>;
chomp @dirschanged;
grep 
{
    # lose the trailing slash if one exists (except in the case of '/')
    $_ =~ s/(.+)[\/\\]$/$1/;
} 
@dirschanged; 
close (INPUT);

# figure out what's changed (using svnlook)
open (INPUT, "$svnlook $repos rev $rev changed |") 
    or die ("Error running svnlook (changed)");
@svnlooklines = <INPUT>;
close (INPUT);

# parse the changed nodes
my @adds = ();
my @dels = ();
my @mods = ();
foreach my $line (@svnlooklines)
{
    my ($code, $path) = split ('   ', $line);

    if ($code eq 'A') {
        push (@adds, "   $path");
    }
    elsif ($code eq 'D') {
        push (@dels, "   $path");
    }
    else {
        push (@mods, "   $path");
    }
}

# get the diff from svnlook
open (INPUT, "$svnlook $repos rev $rev diff |") 
    or die ("Error running svnlook (diff)");
my @difflines = <INPUT>;
close (INPUT);

# mail headers
my $dirlist = join (' ', @dirschanged);
my $userlist = join (' ', @email_addrs); 
my $subject = "commit: revision $rev - $dirlist";
if ($subject_prefix =~ /\w/)
{
    $subject = "$subject_prefix $subject";
}
my $mail_from = $author;
if ($hostname =~ /\w/)
{
    $mail_from = "$mail_from\@$hostname";
}
push (@output, ("To: $userlist\n"));
push (@output, ("From: $mail_from\n"));
push (@output, ("Subject: $subject\n"));
push (@output, ("\n"));

# mail body
push (@output, ("Author: $author\n"));
push (@output, ("Date: $date\n"));
push (@output, ("New Revision: $rev\n"));
push (@output, ("\n"));<commit_msg>Don't force the word "commit" into the subject line, let that be decided by the caller.  Also, shorten "revision" to "rev".<commit_after>#!/usr/bin/perl -w

# ====================================================================
# commit-email.pl: send a commit email for commit REVISION in
# repository REPOS to some email addresses.
#
# Usage: commit-email.pl REPOS REVISION [OPTIONS] [EMAIL-ADDR ...]
#
# Options:
#    -h hostname       :  Hostname to append to author for 'From:'
#    -l logfile        :  File to while mail contents should be 
#                         appended
#    -s subject_prefix :  Subject line prefix
#    
# ====================================================================
# Copyright (c) 2000-2001 CollabNet.  All rights reserved.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at http://subversion.tigris.org/license-1.html.
# If newer versions of this license are posted there, you may use a
# newer version instead, at your option.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://subversion.tigris.org/.
# ====================================================================

use strict;

######################################################################
#  CONFIGURATION SECTION
######################################################################

# sendmail path
my $sendmail = "/usr/sbin/sendmail";

# svnlook path
my $svnlook = "/usr/local/bin/svnlook";

######################################################################

# get the REPOS from the arguments
my $repos = shift @ARGV;

# get the REVISION from the arguments
my $rev = shift @ARGV;

# initialize the EMAIL_ADDRS to the remaining arguments
my @email_addrs = @ARGV;

# now, we see if there are any options included in the argument list
my $logfile = '';
my $hostname = '';
my $subject_prefix = '';
while (scalar @email_addrs)
{
    my $option = shift @email_addrs;
    if ($option eq '-h')
    {
        # found a hostname option
        $hostname = shift @email_addrs;
    }
    elsif ($option eq '-l')
    {
        # found a logfile option
        $logfile = shift @email_addrs;
    }
    elsif ($option eq '-s')
    {
        # found a subject prefix option
        $subject_prefix = shift @email_addrs;
    }
    else
    {
        # not an option, put it back!
        unshift @email_addrs, ($option);
        last;
    }
}

my @svnlooklines = ();
my @output = ();

# get the auther, date, and log from svnlook
open (INPUT, "$svnlook $repos rev $rev info |") 
    or die ("Error running svnlook (info)");
@svnlooklines = <INPUT>;
close (INPUT);
my $author = shift @svnlooklines;
my $date = shift @svnlooklines;
shift @svnlooklines;
my @log = @svnlooklines;
chomp $author;
chomp $date;

# figure out what directories have changed (using svnlook)
open (INPUT, "$svnlook $repos rev $rev dirs-changed |")
    or die ("Error running svnlook (changed)");
my @dirschanged = <INPUT>;
chomp @dirschanged;
grep 
{
    # lose the trailing slash if one exists (except in the case of '/')
    $_ =~ s/(.+)[\/\\]$/$1/;
} 
@dirschanged; 
close (INPUT);

# figure out what's changed (using svnlook)
open (INPUT, "$svnlook $repos rev $rev changed |") 
    or die ("Error running svnlook (changed)");
@svnlooklines = <INPUT>;
close (INPUT);

# parse the changed nodes
my @adds = ();
my @dels = ();
my @mods = ();
foreach my $line (@svnlooklines)
{
    my ($code, $path) = split ('   ', $line);

    if ($code eq 'A') {
        push (@adds, "   $path");
    }
    elsif ($code eq 'D') {
        push (@dels, "   $path");
    }
    else {
        push (@mods, "   $path");
    }
}

# get the diff from svnlook
open (INPUT, "$svnlook $repos rev $rev diff |") 
    or die ("Error running svnlook (diff)");
my @difflines = <INPUT>;
close (INPUT);

# mail headers
my $dirlist = join (' ', @dirschanged);
my $userlist = join (' ', @email_addrs); 
my $subject = "rev $rev - $dirlist";
if ($subject_prefix =~ /\w/)
{
    $subject = "$subject_prefix $subject";
}
my $mail_from = $author;
if ($hostname =~ /\w/)
{
    $mail_from = "$mail_from\@$hostname";
}
push (@output, ("To: $userlist\n"));
push (@output, ("From: $mail_from\n"));
push (@output, ("Subject: $subject\n"));
push (@output, ("\n"));

# mail body
push (@output, ("Author: $author\n"));
push (@output, ("Date: $date\n"));
push (@output, ("New Revision: $rev\n"));
push (@output, ("\n"));
{'fraction_non_alphanumeric': 0.22580289151307803, 'fraction_numerical': 0.002207261891623441, 'mean_word_length': 3.5652392947103273, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4104607', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2780, 'n_words': 966}