From 7aff860390e1999a7d6a66d2e1447cd1c46772a7 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Wed, 19 Dec 2018 19:16:17 -0500 Subject: [PATCH] Add git clean functionality --- libs/util.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libs/util.py b/libs/util.py index 5ac9f943..c0281715 100644 --- a/libs/util.py +++ b/libs/util.py @@ -59,3 +59,31 @@ def install_requirements( args.append(path) subprocess.call(args) + + +def git_clean(remove_directories=False, force=False, dry_run=False, interactive=False, quiet=False, exclude=None, + ignore_rules=False, clean_ignored=False, paths=None): + command = ['git', 'clean'] + if remove_directories: + command.append('-d') + if force: + command.append('--force') + if interactive: + command.append('--interactive') + if quiet: + command.append('--quiet') + if dry_run: + command.append('--dry-run') + if exclude: + command.append('--exclude={pattern}'.format(pattern=exclude)) + if ignore_rules: + command.append('-x') + if clean_ignored: + command.append('-X') + if paths: + try: + paths = paths.split(' ') + except AttributeError: + pass + command.extend(paths) + subprocess.call(command)