From 7fd7449540b3f456db904e6da01d8c8ff2a27637 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Tue, 2 Feb 2010 14:07:23 -0800 Subject: Add an unused_patches function --- src/fedpkg/__init__.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) 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 -- cgit