diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index dd8eb1372..24cb444de 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1608,7 +1608,8 @@ def _load_forge_config(forge_dir, exclusive_config_file): for old_file in old_files: if old_file.replace(os.sep, "/") in config["skip_render"]: continue - remove_file_or_dir(os.path.join(forge_dir, old_file)) + file_with_path = os.path.join(forge_dir, old_file) + remove_file_or_dir(file_with_path) # Set some more azure defaults config["azure"].setdefault("user_or_org", config["github"]["user_or_org"]) diff --git a/conda_smithy/feedstock_io.py b/conda_smithy/feedstock_io.py index 6878850af..e55851e4d 100644 --- a/conda_smithy/feedstock_io.py +++ b/conda_smithy/feedstock_io.py @@ -63,7 +63,7 @@ def remove_file_or_dir(filename): return remove_file(filename) repo = get_repo(filename) - if repo: + if repo and filename in repo.head.commit.tree: repo.index.remove([filename], r=True) shutil.rmtree(filename) diff --git a/news/bad_remove.rst b/news/bad_remove.rst new file mode 100644 index 000000000..8e5af7f61 --- /dev/null +++ b/news/bad_remove.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Don't try to remove files that don't exist + +**Security:** + +*