Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
89207b3a
Commit
89207b3a
authored
Feb 15, 2012
by
Nicolas Dandrimont
🤔
Browse files
Overhaul the diffclean plugin
parent
fdf21b86
Changes
3
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/diffclean.py
View file @
89207b3a
...
@@ -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'
,
diffst
at
,
constants
.
PLUGIN_SEVERITY_
ERROR
)
self
.
failed
(
"The package's .diff.gz modifies files outside of debian/"
,
d
at
a
,
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'
},
}
debexpo/templates/plugins/diffclean/html.mako
0 → 100644
View file @
89207b3a
<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
debexpo/templates/plugins/diffclean/text.mako
0 → 100644
View file @
89207b3a
${o.outcome}
%if o.rich_data["dirty"]:
Modified files:
%for filename, stat in o.rich_data["modified-files"]:
${filename} | ${stat}
%endfor
%endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment