Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use $HOME/.tidyall.ini if not found tidyall.ini #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/tidyall
Expand Up @@ -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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just wrong, since the file is either tidyall.ini (no dot) or .tidyallrc. You'd need to check for both.

Better to check something like:

... if dirname($conf_file) eq $ENV{HOME};

my $ct = $tidyall_class->new_from_conf_file( $conf_file, %params );

my @files;
Expand Down
3 changes: 2 additions & 1 deletion lib/Code/TidyAll.pm
Expand Up @@ -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'" );
Expand Down
10 changes: 9 additions & 1 deletion lib/Code/TidyAll/Git/Precommit.pm
Expand Up @@ -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 ) {
Expand Down