summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Keating <jkeating@redhat.com>2010-02-02 14:07:23 -0800
committerJesse Keating <jkeating@redhat.com>2010-02-02 14:07:23 -0800
commit7fd7449540b3f456db904e6da01d8c8ff2a27637 (patch)
tree768f5469de7ba35d5e8019b41419a1e2cec0df12
parent799ebd989805e2dc4ba00ecdfbbc0c43eccababe (diff)
downloadfedpkg-7fd7449540b3f456db904e6da01d8c8ff2a27637.tar.gz
fedpkg-7fd7449540b3f456db904e6da01d8c8ff2a27637.tar.xz
fedpkg-7fd7449540b3f456db904e6da01d8c8ff2a27637.zip
Add an unused_patches function
-rw-r--r--src/fedpkg/__init__.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/fedpkg/__init__.py b/src/fedpkg/__init__.py
index 0d82edc..cf6a44a 100644
--- a/src/fedpkg/__init__.py
+++ b/src/fedpkg/__init__.py
@@ -722,4 +722,25 @@ class PackageModule:
subprocess.check_call(' '.join(cmd), shell=True)
except subprocess.CalledProcessError, e:
raise FedpkgError('Could not build %s: %s' % (self.module, e))
- return \ No newline at end of file
+ return
+
+ def unused_patches(self):
+ """Discover patches checked into source control that are not used
+
+ Returns a list of unused patches, which may be empty.
+
+ """
+
+ # Create a list for unused patches
+ unused = []
+ # Get the content of spec into memory for fast searching
+ spec = open(self.spec, 'r').read()
+ # Get a list of files tracked in source control
+ files = self.repo.git.ls_files('--exclude-standard').split()
+ for file in files:
+ # throw out non patches
+ if not file.endswith('.patch'):
+ continue
+ if file not in spec:
+ unused.append(file)
+ return unused \ No newline at end of file