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

Confusing meaning of --conf-file, --root-dir, global ignore and symlinks #95

Open
biffen opened this issue Jun 24, 2019 · 0 comments
Open

Comments

@biffen
Copy link

biffen commented Jun 24, 2019

I’d like to be able to run tidyall on a project but have a configuration file located somewhere else.

Using --conf-file does not seem to simply read configuration from the specified file, but also changes the root directory to that of the file. Is this a deliberate functionality? If so, it would be nice if it was documented.

Then using --root-dir to ‘correct’ this, it seems global ignores don’t work as I would expect.

The following code reproduces the ‘issue’:

docker run -i --rm perl sh -esux <<EOF
cpanm -nq Code::TidyAll >/dev/null
tidyall --version

mkdir -p a b/d
echo x > a/c
echo x > b/f
echo y > b/d/e

cat > a/.tidyallrc <<EOF2
ignore = d/**


[GenericValidator / x]
argv                            = x
cmd                             = grep
select                          = **/*
EOF2

cd a

tidyall --all --no-cache --verbose

cd ../b

tidyall --all --conf-file ../a/.tidyallrc --no-cache --verbose

tidyall --all --conf-file ../a/.tidyallrc --no-cache --root-dir . --verbose || :

ln -s ../a/.tidyallrc .tidyallrc
tidyall --all --no-cache --verbose
EOF

(It uses docker but the sh code could be run locally.)

It creates the following files:

a/
├── .tidyallrc
└── c
b/
├── d/
│   └── e
└── f

And a Tidy::All configuration that checks for an x in each file, but ignores d/**.

When run in a/ the result is as I expect; it tests a/c:

constructing Code::TidyAll with these params: {ignore => ['d/**'],no_cache => 1,plugins => {'GenericValidator / x' => {argv => 'x',cmd => 'grep',select => ['**/*']}},root_dir => '/root/a',verbose => 1}
purging old backups
[applying the following plugins: GenericValidator / x]
[checked] c (GenericValidator / x)

But when run in b/ with --conf-file ../a/.tidyallrc it still (only) tests a/c:

constructing Code::TidyAll with these params: {ignore => ['d/**'],no_cache => 1,plugins => {'GenericValidator / x' => {argv => 'x',cmd => 'grep',select => ['**/*']}},root_dir => '/root/a',verbose => 1}
[applying the following plugins: GenericValidator / x]
[checked] c (GenericValidator / x)

Adding --root-dir . makes it test b/f as expected, but it also tests (and fails on) b/d/e, which I would expect it to ignore:

constructing Code::TidyAll with these params: {ignore => ['d/**'],no_cache => 1,plugins => {'GenericValidator / x' => {argv => 'x',cmd => 'grep',select => ['**/*']}},root_dir => '.',verbose => 1}
purging old backups
[applying the following plugins: GenericValidator / x]
[checked] f (GenericValidator / x)
[applying the following plugins: GenericValidator / x]
[checked] d/e (GenericValidator / x)
grep x /tmp/Code-TidyAll-MJAz/d/e failed
    exited with 1

As a final test I tried making a symlink from b/.tidyallrc to a/.tidyallrc, but that, to my great surprise, made the whole thing run in a:

constructing Code::TidyAll with these params: {ignore => ['d/**'],no_cache => 1,plugins => {'GenericValidator / x' => {argv => 'x',cmd => 'grep',select => ['**/*']}},root_dir => '/root/a',verbose => 1}
[applying the following plugins: GenericValidator / x]
[checked] c (GenericValidator / x)
  • Was I wrong in thinking --conf-dir would just specify a different configuration file?

  • Am I wrong in how I think the global ignores should work?

  • Are symlinked configuration files supposed to behave like above?!

  • Is there some other, well-defined, way of using a configuration file located outside of the current directory but have it behave in all other ways as if it was in the current directory?

Oh, and thanks for the great software. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant