diff --git a/debian/changelog b/debian/changelog index d4fde44..c72bd45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,10 @@ ubuntu-dev-tools (0.137) UNRELEASED; urgency=low * mk-sbuild, pbuilder-dist, ubuntu-build: Add armhf. * pull-debian-source, pull-lp-source: Resolve the source package (via DDE), if a binary package was requested (LP: #617349) + * submittodebian: + - Do the report boiler-plate checking in a script that wraps an editor, so + that we only edit the report once, after checking for duplicates. + - rm the tmpdir with a little more force (shutil.rmtree) (LP: #899399) [ Andreas Moog ] * sponsor-patch: Check permission to unsubscribe sponsors-team (LP: #896884) diff --git a/debian/copyright b/debian/copyright index d3963b3..98ffaf6 100644 --- a/debian/copyright +++ b/debian/copyright @@ -151,6 +151,7 @@ Files: doc/pull-debian-debdiff.1 doc/sponsor-patch.1 doc/ubuntu-dev-tools.5 doc/update-maintainer.1 + enforced-editing-wrapper pull-debian-debdiff pull-debian-source requestbackport diff --git a/enforced-editing-wrapper b/enforced-editing-wrapper new file mode 100755 index 0000000..27917f8 --- /dev/null +++ b/enforced-editing-wrapper @@ -0,0 +1,62 @@ +#!/usr/bin/python +# +# Copyright (C) 2011, Stefano Rivera +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# +# +# Wraps sensisible-editor in checks for remaining boilerplate. +# Configured through environment variables: +# UDT_EDIT_WRAPPER_EDITOR: The user's usual $EDITOR +# UDT_EDIT_WRAPPER_VISUAL: The user's usual $VISUAL +# UDT_EDIT_WRAPPER_TEMPLATE_RE: An extra boilerplate-detecting regex. +# UDT_EDIT_WRAPPER_FILE_DESCRIPTION: The type of file being edited. + +import optparse +import os +import re + +from ubuntutools.question import EditFile + + +def main(): + parser = optparse.OptionParser('%prog [options] filename') + options, args = parser.parse_args() + + if len(args) != 1: + parser.error('A filename must be specified') + body = args[0] + if not os.path.isfile(body): + parser.error('File %s does not exist' % body) + + if 'UDT_EDIT_WRAPPER_EDITOR' in os.environ: + os.environ['EDITOR'] = os.environ['UDT_EDIT_WRAPPER_EDITOR'] + else: + del os.environ['EDITOR'] + + if 'UDT_EDIT_WRAPPER_VISUAL' in os.environ: + os.environ['VISUAL'] = os.environ['UDT_EDIT_WRAPPER_VISUAL'] + else: + del os.environ['VISUAL'] + + placeholders = [] + if 'UDT_EDIT_WRAPPER_TEMPLATE_RE' in os.environ: + placeholders.append(re.compile( + os.environ['UDT_EDIT_WRAPPER_TEMPLATE_RE'])) + + description = os.environ.get('UDT_EDIT_WRAPPER_FILE_DESCRIPTION', 'file') + + EditFile(body, description, placeholders).edit() + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 36dd05a..558b8e1 100755 --- a/setup.py +++ b/setup.py @@ -58,6 +58,7 @@ if __name__ == '__main__': glob.glob("bash_completion/*")), ('share/man/man1', glob.glob("doc/*.1")), ('share/man/man5', glob.glob("doc/*.5")), + ('share/ubuntu-dev-tools', ['enforced-editing-wrapper']), ], test_suite='ubuntutools.test.discover', ) diff --git a/submittodebian b/submittodebian index f7501bb..48122a7 100755 --- a/submittodebian +++ b/submittodebian @@ -24,6 +24,7 @@ import os import re +import shutil import sys from tempfile import mkdtemp @@ -118,11 +119,35 @@ def check_file(fname, critical = True): def submit_bugreport(body, debdiff, deb_version, changelog): devel = UbuntuDistroInfo().devel() - cmd = ('reportbug', '-P', 'User: ubuntu-devel@lists.ubuntu.com', - '-P', 'Usertags: origin-ubuntu %s ubuntu-patch' % devel, - '-T', 'patch', '-A', debdiff, '-B', 'debian', '-i', body, - '-V', deb_version, changelog.package) - check_call(cmd) + + if os.path.dirname(sys.argv[0]).startswith('/usr/bin'): + editor_path = '/usr/share/ubuntu-dev-tools' + else: + editor_path = os.path.dirname(sys.argv[0]) + env = dict(os.environ.items()) + if 'EDITOR' in env: + env['UDT_EDIT_WRAPPER_EDITOR'] = env['EDITOR'] + if 'VISUAL' in env: + env['UDT_EDIT_WRAPPER_VISUAL'] = env['VISUAL'] + env['EDITOR'] = os.path.join(editor_path, 'enforced-editing-wrapper') + env['VISUAL'] = os.path.join(editor_path, 'enforced-editing-wrapper') + env['UDT_EDIT_WRAPPER_TEMPLATE_RE'] = ( + '.*REPLACE THIS WITH ACTUAL INFORMATION.*') + env['UDT_EDIT_WRAPPER_FILE_DESCRIPTION'] = 'bug report' + + cmd = ('reportbug', + '--no-check-available', + '--no-check-installed', + '--pseudo-header', 'User: ubuntu-devel@lists.ubuntu.com', + '--pseudo-header', 'Usertags: origin-ubuntu %s ubuntu-patch' % devel, + '--tag', 'patch', + '--attach', debdiff, + '--bts', 'debian', + '--include', body, + '--package-version', deb_version, + changelog.package) + check_call(cmd, env=env) + def check_reportbug_config(): fn = os.path.expanduser('~/.reportbugrc') @@ -182,14 +207,11 @@ def main(): debdiff = gen_debdiff(tmpdir, changelog) EditFile(debdiff, 'debdiff').edit(optional=True) - EditFile(body, 'bug report', [ - re.compile('.*REPLACE THIS WITH ACTUAL INFORMATION.*') - ]).edit() submit_bugreport(body, debdiff, deb_version, changelog) os.unlink(body) os.unlink(debdiff) - os.rmdir(tmpdir) + shutil.rmtree(tmpdir) if __name__ == '__main__': main()