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

use strict;
use warnings;

use Git;
use File::Slurp qw(read_file write_file);

use v5.12;

my $comment = shift || "No comment";
my $words=  'texto/palabras';

my $git = Git->repository;

my $branch =  $git->command(qw/rev-parse --abbrev-ref HEAD/);
say "Pre-commit hook (falso) en $branch";
if ( $branch =~ /master/ ) {
  my $changed = $git->command(qw/diff --name-status/);
  my @changed_files = ($changed =~ /\s*\w\s+(\S+)/g);
  if ( $words ~~ @changed_files ) {
    my $file_name = ( -e $words)? $words: "palabras";
    `aspell --lang=es --encoding=utf-8 create master texto/hashslash.dic < $words`
  }
  $git->command( "commit", "-a", "-m", $comment );
  $git->command( "push" );
}


=head1 NAME

commit.pl - process stuff and eventually do a commit and push

=head2 SYNOPSIS

First you need to install C<File::Slurp>. I use say,
so you will need perl > 5.10. Besides, you need to locate Git.pm and
copy it where this script can find it. That depends on the OS and perl
installation you're using (I use perlbrew), In my case it was:

  bash% cp /usr/share/perl5/Git.pm ~/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/

Then it's just
<commit_msg>Comprueba el programa que commitea<commit_after>#!/usr/bin/env perl

use strict;
use warnings;

use Git;
use File::Slurp qw(read_file write_file);

use v5.12;

my $comment = shift || "No comment";
my $words=  'texto/palabras';

my $git = Git->repository;

my $branch =  $git->command(qw/rev-parse --abbrev-ref HEAD/);
say "Pre-commit hook (falso) en $branch";
if ( $branch =~ /master/ ) {
  my $changed = $git->command(qw/diff --name-status/);
  my @changed_files = ($changed =~ /\s*\w\s+(\S+)/g);
  if ( $words ~~ @changed_files ) {
    my $file_name = ( -e $words)? $words: "palabras";
    my $generate_dic = "aspell --lang=es --encoding=utf-8 create master texto/hashslash.dic < $words";
    say $generate_dic;
    my $result = `$generate_dic`;
  }
  $git->command( "commit", "-a", "-m", $comment );
  $git->command( "push" );
}


=head1 NAME

commit.pl - process stuff and eventually do a commit and push

=head2 SYNOPSIS

First you need to install C<File::Slurp>. I use say,
so you will need perl > 5.10. Besides, you need to locate Git.pm and
copy it where this script can find it. That depends on the OS and perl
installation you're using (I use perlbrew), In my case it was:

  bash% cp /usr/share/perl5/Git.pm ~/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/

Then it's just

{'fraction_non_alphanumeric': 0.16452131938857603, 'fraction_numerical': 0.015285599356395816, 'mean_word_length': 3.505434782608696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '1917884', 'n_tokens_mistral': 986, 'n_tokens_neox': 946, 'n_words': 289}