summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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