Ignore exact files within the root directory #947
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
Currently, if a file is a top-level file within a repository and is added to git secret, the filename added to
.gitignorewill subsequently ignore all files with that name in further sub-directories.This can cause some unintended behaviors if you are using git-secret in a mixed repository where there are both encrypted and unencrypted files as any file within sub-directories will be ignored. Adding files to both the
.gitignoreand.git-secret/mapping.cfgutilizegit ls-filesto output the filename and then prepends the path to it in subsequent functions. To fix this issue, if a file is within the root directory (i.e., the path does not contain a/), I prepended a/to the filename so that git ignore works as intended.Does this close any currently open issues?
No
Steps to Reproduce
Current version: git-secret 0.5.0-alpha2
.gitignoreandgit-secretwill beFILENAMEAny other comments?
While this can be fixed by editing the
.gitignorewhenever it causes conflict, this PR just stops the behavior from stopping it in the first place.