summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-01-05 15:10:58 -0800
committerJesse Keating <jkeating@redhat.com>2010-01-05 15:10:58 -0800
commit16eae678baa4631a72f58ab6f5c3688ca234e4a9 (patch)
tree1a5641a3e31b0afb185d88ac7ebefb47daaaf0ee /src
parent96389214fefcc0a0bc265ac69673830dd57e6e59 (diff)
downloadfedpkg-16eae678baa4631a72f58ab6f5c3688ca234e4a9.tar.gz
fedpkg-16eae678baa4631a72f58ab6f5c3688ca234e4a9.tar.xz
fedpkg-16eae678baa4631a72f58ab6f5c3688ca234e4a9.zip
Add a clean function
Diffstat (limited to 'src')
-rw-r--r--src/fedpkg/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py
index 99b3e5e..77bd658 100644
--- a/src/fedpkg/__init__.py
+++ b/src/fedpkg/__init__.py
@@ -91,6 +91,37 @@ def _get_build_arches_from_srpm(srpm, arches):
raise FedpkgError('No compatible build arches found in %s' % srpm)
return archlist
+def clean(dry=False, useignore=True):
+ """Clean a module checkout of untracked files.
+
+ Can optionally perform a dry-run
+
+ Can optionally not use the ignore rules
+
+ Returns output
+
+ """
+
+ # setup the command, this could probably be done with some python api...
+ cmd = ['git', 'clean', '-f', '-d']
+ if dry:
+ cmd.append('--dry-run')
+ if not useignore:
+ cmd.append('-x')
+ # Run it!
+ try:
+ proc = subprocess.Popen(cmd, stderr=subprocess.STDOUT,
+ stdout=subprocess.PIPE)
+ output = proc.communicate()
+ except OSError, e:
+ raise FedpkgError(e)
+ # See if we exited cleanly
+ if proc.returncode:
+ raise FedpkgError('%s returned %s: %s' %
+ (subprocess.list2cmdline(cmd),
+ proc.returncode, output[0]))
+ return output[0]
+
def clone(module, user, branch=None):
"""Clone a repo, optionally check out a specific branch.