-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Fix: Exclude not working with absolute path in some cases (#593) #618
base: main
Are you sure you want to change the base?
Conversation
5a5a878
to
4293812
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Need changelogs for:
- the fix
- changing undocumented behavior that exclude paths are now relative to the config file instead of where selene is invoked
We should also properly document that in https://kampfkarren.github.io/selene/usage/configuration.html#excluding-files-from-being-linted
Path::new(&config_file).parent().map(Path::to_path_buf), | ||
), | ||
Ok(config) => { | ||
// Get config directory to using absolute path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Get config directory to using absolute path. |
// There is case where `config = Some("selene.toml")`, | ||
// which returns `""`` when getting parent directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
let config_directory = Path::new(&config_file) | ||
.canonicalize() | ||
.ok() | ||
.and_then(|path| path.parent().map(|path| path.to_path_buf())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.and_then(|path| path.parent().map(|path| path.to_path_buf())); | |
.and_then(|path| path.parent().map(Path::to_path_buf)); | |
@@ -512,6 +512,7 @@ fn start(mut options: opts::Options) { | |||
|
|||
let (config, config_directory): (CheckerConfig<toml::value::Value>, Option<PathBuf>) = | |||
match options.config { | |||
// User provides a config file. We must read it and report if it is misconfigured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// User provides a config file. We must read it and report if it is misconfigured. |
// Directory for matching files pattern. | ||
// If user provides a config file, we use that as our working directory, otherwise fallback to the current directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Directory for matching files pattern. | |
// If user provides a config file, we use that as our working directory, otherwise fallback to the current directory. |
@@ -636,6 +643,26 @@ fn start(mut options: opts::Options) { | |||
|
|||
let pool = ThreadPool::new(options.num_threads); | |||
|
|||
// Directory for matching files pattern. | |||
// If user provides a config file, we use that as our working directory, otherwise fallback to the current directory. | |||
// The working directory needs to be an absolute path to match with paths in different directories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't explain why relative path won't work. Can we either clarify that?
return false; | ||
} | ||
|
||
// File pattern between the path we are checking and current working directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// File pattern between the path we are checking and current working directory. |
Fix #593
Exclude files if they match exclude patterns using working directory (config directory if a config file is provided, otherwise it is the current directory) as a base.
I'm not sure whether I should add testcases for this, since this requires refactor into smaller functions.