neocities / neocities-ruby

The Neocities Gem - A CLI and library for using the Neocities web site API.
https://neocities.org
52 stars 14 forks source link

`neocities push .` incorrectly applying .gitignore rules. #48

Open MesropM opened 10 months ago

MesropM commented 10 months ago

neocities push . will attempt to push files that should be ignored as per the .gitignore file.

I am on a mac and so I have .DS_Store in my .gitignore. Pushing ignores the .DS_Store file in the directory I run it from, but will attempt to push any .DS_Store files it finds in other directories.

For example, I have a folder called fonts, and this has a .DS_Store file in side of it. When attempting to push, neocities will ignore the .DS_Store file in the directory its run from (as expected from the .gitignore), but will attempt to push (and fail to do so) when it finds the .DS_Store file in the fonts directory.

If I try to specify fonts/.DS_Store in my .gitignore file, neocities will successfully ignore the file, but I will have to do this for every directory. It seems that the push command does not check for ignored files in every directory, only the directory it's run from.

It was working as expected, but when I updated to the latest version 0.0.18, this issue began (I do not know which version I updated from).

vadcx commented 8 months ago

git check-ignore can be used in a streaming fashion to check any path for ignore rules with only one process invocation:

Command: git check-ignore --no-index --stdin -v
STDIN: here.mysecret <Press Enter or Enter+CTRL-D to end>
STDOUT (after sending the line): .gitignore:1:**.mysecret  here.mysecret

.gitignore:

**.mysecret

This works correctly with any complexity of git's ignore rules and will pick up the repository even if it's in a parent folder. It only DOES NOT ignore the own .git folder by default. Git must have a special handling of its own folder.

The fix should be a relatively simple CLI interaction between neocities and git (#47). The current approach is broken or outright unsafe for possibly leaking secrets. Link to current code I'd have done it if I had any idea of ruby.