Commit 89207b3a authored by Nicolas Dandrimont's avatar Nicolas Dandrimont 🤔
Browse files

Overhaul the diffclean plugin

parent fdf21b86
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
# This file is part of debexpo - http://debexpo.workaround.org # This file is part of debexpo - http://debexpo.workaround.org
# #
# Copyright © 2008 Jonny Lamb <jonny@debian.org> # Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2012 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
# #
# Permission is hereby granted, free of charge, to any person # Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation # obtaining a copy of this software and associated documentation
...@@ -32,7 +33,10 @@ Holds the diffclean plugin. ...@@ -32,7 +33,10 @@ Holds the diffclean plugin.
""" """
__author__ = 'Jonny Lamb' __author__ = 'Jonny Lamb'
__copyright__ = 'Copyright © 2008 Jonny Lamb' __copyright__ = ', '.join([
'Copyright © 2008 Jonny Lamb',
'Copyright © 2012 Nicolas Dandrimont',
])
__license__ = 'MIT' __license__ = 'MIT'
import subprocess import subprocess
...@@ -59,22 +63,23 @@ class DiffCleanPlugin(BasePlugin): ...@@ -59,22 +63,23 @@ class DiffCleanPlugin(BasePlugin):
diffstat = subprocess.Popen(["diffstat", "-p1", difffile], stdout=subprocess.PIPE).communicate()[0] diffstat = subprocess.Popen(["diffstat", "-p1", difffile], stdout=subprocess.PIPE).communicate()[0]
dirty = False data = {
for item in diffstat.split('\n')[:-1]: "dirty": False,
if not item.startswith(' debian/'): "modified-files": [],
dirty = True }
break
if not dirty: # Last line is the summary line
for item in diffstat.splitlines()[:-1]:
filename, stats = [i.strip() for i in item.split("|")]
if not filename.startswith('debian/'):
data["dirty"] = True
data["modified-files"].append((filename, stats))
if not data["dirty"]:
log.debug('Diff file %s is clean' % difffile) log.debug('Diff file %s is clean' % difffile)
self.passed('diff-clean', None, constants.PLUGIN_SEVERITY_INFO) self.passed("The package's .diff.gz does not modify files outside of debian/", data, constants.PLUGIN_SEVERITY_INFO)
else: else:
log.error('Diff file %s is not clean' % difffile) log.error('Diff file %s is not clean' % difffile)
self.failed('diff-dirty', diffstat, constants.PLUGIN_SEVERITY_ERROR) self.failed("The package's .diff.gz modifies files outside of debian/", data, constants.PLUGIN_SEVERITY_WARNING)
plugin = DiffCleanPlugin plugin = DiffCleanPlugin
outcomes = {
'diff-clean' : { 'name' : 'The diff.gz file is clean' },
'diff-dirty' : { 'name' : 'The diff.gz file is dirty' },
}
<div class="qa-header">
${str(o.outcome)}
</div>
%if o.rich_data["dirty"]:
<div class="qa-content">
<table>
<th><td>Modified file</td><td>diffstat</td></th>
%for filename, stat in o.rich_data["modified-files"]:
<tr><td>${filename}</td><td>${stat}</td></tr>
%endfor
</table>
</div>
%endif
${o.outcome}
%if o.rich_data["dirty"]:
Modified files:
%for filename, stat in o.rich_data["modified-files"]:
${filename} | ${stat}
%endfor
%endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment