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

Add --fullpath option #100

Merged
merged 2 commits into from
Jan 5, 2025
Merged

Add --fullpath option #100

merged 2 commits into from
Jan 5, 2025

Conversation

hhatto
Copy link
Owner

@hhatto hhatto commented Dec 26, 2024

Added --fullpath option to be enabled for the --match and --not-match options.
While --match / --not-match options determined regex matches/not-matches only for basenames.
When --fullpath option is specified, match/not-match are determined for the entire file path.

ref: #93

@hhatto hhatto self-assigned this Dec 26, 2024
Comment on lines 83 to +89
func checkOptionMatch(path string, info os.FileInfo, opts *ClocOptions) bool {
// check match directory & file options
if opts.ReNotMatch != nil && opts.ReNotMatch.MatchString(info.Name()) {
targetFile := info.Name()
if opts.Fullpath {
targetFile = path
}

Choose a reason for hiding this comment

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

Perhaps we should do filepath.Clean(path) to handle cases where ./dir/file.py is equal to dir/file.py?

Copy link
Owner Author

Choose a reason for hiding this comment

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

This path will be the value specified from gocloc's CLI options or the value of filepath.Walk in the specified directory.
If it is a value specified from the CLI option of gocloc, it should not be Cleaned because it will be a user input.
In the case of the value of filepath.Walk, it will be a Cleaned value and should not be Cleaned.

So we think Clean is not necessary here.

@cclarkedt
Copy link

This feature will be great to use, thank you

@hhatto hhatto merged commit 59331e3 into master Jan 5, 2025
8 checks passed
@hhatto hhatto deleted the add-fullpath-option branch January 5, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants