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 backup files #556

Open
Dreamsorcerer opened this issue Oct 23, 2023 · 5 comments
Open

Ignore backup files #556

Dreamsorcerer opened this issue Oct 23, 2023 · 5 comments

Comments

@Dreamsorcerer
Copy link

From #448 (comment)

I get an error when it fails to git remove some hidden backup files on my computer.

Personally, I'd be fine if it simply skipped any files which are not committed, but I see there are planned changes to go in the other direction, in which case simply ignoring common backup files would be fine too.

The backup files in my case all end with ~. This is a common pattern on Linux systems and are treated as hidden files by a lot of software (similar to starting with .).

@adiroiban
Copy link
Member

If someone will send a good PR to ignore any files that are not in git, we can merge it :)

To me it makes sense to ignore the files that are not in git.

towncrier is all about gathering the files from multiple branches.

@Dreamsorcerer
Copy link
Author

Dreamsorcerer commented Oct 23, 2023

This would contradict the changes in #357, so if we're saying that we definitely won't handle untracked files in future, then that should be closed.

If we do go this way, then a quick search suggests a simple solution could be to run git ls-tree --full-tree -r --name-only HEAD [path-to-change-fragments], which will give us a list of tracked files. Then we could simply use that instead of browsing the directory, I suppose.

@Dreamsorcerer
Copy link
Author

Which would also solve #448 easily.

@Dreamsorcerer
Copy link
Author

Dreamsorcerer commented Oct 23, 2023

So, I reckon just replacing

files = os.listdir(section_dir)

With a git call to git ls-tree --full-tree --name-only HEAD {section_dir} may be enough, though I've not tried anything yet.

@adiroiban
Copy link
Member

adiroiban commented Oct 23, 2023

Sound very good. Thanks.

Anythig that has good automated tests and doesn't break the current test suite should be good enogh to be merged.

We are already calling git in various places, so calling it one more time snould not be a problem.

Also, as we are going to call git rm on the files, I think that it makes sense to also obtain the list of files using git.

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

No branches or pull requests

2 participants