mirror of
https://git.centos.org/centos/centpkg.git
synced 2025-02-23 16:22:55 +00:00
reimplement the unused-patches command for the CentOS layout
This commit is contained in:
parent
e7fd56b5d0
commit
1fe6e4da57
1 changed files with 24 additions and 2 deletions
|
@ -291,6 +291,28 @@ class Commands(Commands):
|
|||
def prep(self, *args, **kwargs):
|
||||
raise NotImplementedError("prep is not yet implemented in centpkg")
|
||||
|
||||
def unused_patches(self, *args, **kwargs):
|
||||
raise NotImplementedError("unused_patches is not yet implemented in centpkg")
|
||||
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()
|
||||
# Replace %{name} with the package name
|
||||
spec = spec.replace("%{name}", self.module_name)
|
||||
# Replace %{version} with the package version
|
||||
spec = spec.replace("%{version}", self.ver)
|
||||
|
||||
# Get a list of files tracked in source control
|
||||
files = self.repo.git.ls_files('--exclude-standard').split()
|
||||
for file in map(os.path.basename, files):
|
||||
# throw out non patches
|
||||
if not file.endswith(('.patch', '.diff')):
|
||||
continue
|
||||
if file not in spec:
|
||||
unused.append(file)
|
||||
return unused
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue