Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@joshuali925
Copy link
Contributor

filepath.Base("") is .. so when copying a hidden file like .gitignore to the same place, it becomes ..gitignore.~1~

this PR fixes the case when basename should be empty

Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

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

Thanks for your patch, I can reproduce the issue as well.

About your changes, filepath.Base is already called a few lines above to remove the leading path components, so I don't think it is required again, and instead the following code should work:

basename := file[:len(file)-len(ext)]

Or alternatively:

basename := strings.TrimSuffix(file, ext)

@joshuali925
Copy link
Contributor Author

thanks for taking a look, updated

Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

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

Looks good, thanks once again for the bugfix.

@joelim-work joelim-work merged commit 31f4a4e into gokcehan:master Dec 11, 2023
@gokcehan gokcehan mentioned this pull request Mar 31, 2024
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