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

Ignore exact files within the root directory #947

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

oliikit
Copy link

@oliikit oliikit commented Oct 25, 2022

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 .gitignore will 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 .gitignore and .git-secret/mapping.cfg utilize git ls-files to 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

  1. Add a file within the root directory to git-secret
    1. the file in both .gitignore and git-secret will be FILENAME
  2. Commit the file
  3. Add a file in a sub-directory with the same name as in step 1.
    1. Result: file will be ignored - even if was intended to be added to git

Any other comments?

While this can be fixed by editing the .gitignore whenever it causes conflict, this PR just stops the behavior from stopping it in the first place.

@oliikit oliikit changed the title Ignore exact Ignore exact files within the root directory Oct 25, 2022
@joshrabinowitz
Copy link
Collaborator

joshrabinowitz commented Oct 31, 2022

@oliikit do these changes pass git-secret's self-tests for you?

Have not investigated but i'm seeing several test failures on multiple platforms in the auto tests in the github actions.

@oliikit
Copy link
Author

oliikit commented Oct 31, 2022

@joshrabinowitz - I've been meaning to check out the different platform errors. Admittedly, I'm on macOS 12.6 and had passing tests locally. I'm planning on taking a look at the other failed platform tests later this week.

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