pydoit / doit

CLI task management & automation tool
http://pydoit.org
MIT License
1.84k stars 175 forks source link

Cleaning all doesn't seem to work #444

Closed tehe closed 1 year ago

tehe commented 1 year ago

Bug description

When there's the default_tasks specified in the dodo.py file, the doit clean --clean-all doesn't clean all targets.

from typing import Dict

DOIT_CONFIG = {'default_tasks': ['echo']}

def task_echo() -> Dict:
    return {
        'actions': ['echo xxx']
    }

def task_dir() -> Dict:
    return {
        'actions': ["mkdir xxx"],
        'clean': ["rm -rfv xxx"]
    }

The only way to have the dir task be cleaned is to explicitly specify its name on the command-line, i.e. doit clean dir.

Environment

  1. OS: Linux Debian Bullseye 11.5
  2. python version: 3.9.2
  3. doit version: 0.36.0

Proposed fix

The following change seems to fix the issue for me

diff --git a/doit/cmd_clean.py b/doit/cmd_clean.py
index 7cdc90a..899b88d 100644
--- a/doit/cmd_clean.py
+++ b/doit/cmd_clean.py
@@ -99,7 +99,7 @@ class Clean(DoitCmdBase):
         else:
             # if not cleaning specific task enable clean_dep automatically
             cleandep = True
-            if self.sel_tasks is not None:
+            if self.sel_tasks is not None and not cleanall:
                 clean_list = self._expand(self.sel_tasks)  # default tasks from config
             else:
                 clean_list = [t.name for t in self.task_list]
schettino72 commented 1 year ago

thanks

tehe commented 1 year ago

Thank you!