﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31283	"""collecstatic --clear"" could take ignored patterns into consideration"	Mateusz Papiernik	nobody	"When calling `collectstatic --clear` all files from `STATIC_ROOT` are cleared, as per documentation (see #22891), which is understandable.

However, `collectstatic` has `--ignore PATTERN` option as well as the possibility to configure ignored patterns through `StaticFilesConfig` and `ignore_patterns` variable. This is a handy feature that by default ignores some auxiliary files **['CVS', '.*', '*~']** during collecting process.

The documentation is lax about that, but `--clear` is not taking those patterns into account, while I think it could.

The most obvious scenario I've run into was with a project that had `static` folder commited to the repository with `.gitkeep` and/or `.gitignore` file inside, to make sure the directory is present, clearly visible from the outset in the project tree and accounted for.

Running `collectstatic --clear` clears all the directory contents, including `.gitkeep` that would be matched by **['CVS', '.*', '*~']** if pattern ignores were considered during clearing. As a result, Git will start treating this directory as untracked one, and missing `.git*` as a uncommited changeset.

Ideally, the `--clear` option would respect `--ignore` and `StaticFilesConfig`, hence the feature proposal. Otherwise, the documentation could be a bit more verbose that it's not the case."	New feature	closed	contrib.staticfiles	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
