diff --git a/bin/tidyall b/bin/tidyall index ac550a5e..a39de0cc 100755 --- a/bin/tidyall +++ b/bin/tidyall @@ -54,6 +54,7 @@ if ( ( $all_files || $svn_files || $git_files ) ) { die "cannot use filename(s) with -a/--all, -s/--svn, or -g/--git" if @ARGV; $conf_file ||= $tidyall_class->find_conf_file( cwd() ); + $params{root_dir} = cwd() if $conf_file eq "$ENV{HOME}/.tidyall.ini"; my $ct = $tidyall_class->new_from_conf_file( $conf_file, %params ); my @files; diff --git a/lib/Code/TidyAll.pm b/lib/Code/TidyAll.pm index f7dd5ce6..ac71d55d 100644 --- a/lib/Code/TidyAll.pm +++ b/lib/Code/TidyAll.pm @@ -320,7 +320,8 @@ sub find_conf_file { my $path1 = rel2abs($start_dir); my $path2 = realpath($start_dir); my $conf_file = $class->_find_conf_file_upward($path1) - || $class->_find_conf_file_upward($path2); + || $class->_find_conf_file_upward($path2) + || "$ENV{HOME}/.tidyall.ini"; unless ( defined $conf_file ) { die sprintf( "could not find $ini_name upwards from %s", ( $path1 eq $path2 ) ? "'$path1'" : "'$path1' or '$path2'" ); diff --git a/lib/Code/TidyAll/Git/Precommit.pm b/lib/Code/TidyAll/Git/Precommit.pm index 0e5a459d..4facdf6e 100644 --- a/lib/Code/TidyAll/Git/Precommit.pm +++ b/lib/Code/TidyAll/Git/Precommit.pm @@ -30,7 +30,15 @@ sub check { my $root_dir = capturex( $self->git_path, "rev-parse", "--show-toplevel" ); chomp($root_dir); my $conf_file = join( "/", $root_dir, $self->conf_file ); - die "could not find conf file '$conf_file'" unless -f $conf_file; + my $global_conf_file = "$ENV{HOME}/.tidyall.ini"; + unless ( -f $conf_file ) { + unless ( -f $global_conf_file ) { + die "could not find conf file '$conf_file', '$global_conf_file'"; + } + else { + $conf_file = $global_conf_file; + } + } # Store the stash, and restore it upon exiting this scope unless ( $self->no_stash ) {