mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-07 15:01:34 +00:00
syncpackage: Add option to close additional Launchpad bugs.
This commit is contained in:
parent
b86063c27f
commit
d54b89e4c1
36
syncpackage
36
syncpackage
@ -101,7 +101,26 @@ def dsc_getfiles(dsc):
|
|||||||
f.close()
|
f.close()
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def sync_dsc(dscurl, debian_dist, release, uploader, keyid=None, verbose=False):
|
def add_fixed_bugs(changes, bugs, verbose=False):
|
||||||
|
'''Add additional Launchpad bugs to the list of fixed bugs in changes file.'''
|
||||||
|
|
||||||
|
changes = filter(lambda l: l.strip() != "", changes.split("\n"))
|
||||||
|
# Remove duplicates
|
||||||
|
bugs = set(bugs)
|
||||||
|
|
||||||
|
for i in xrange(len(changes)):
|
||||||
|
if changes[i].startswith("Launchpad-Bugs-Fixed:"):
|
||||||
|
bugs.update(changes[i][22:].strip().split(" "))
|
||||||
|
changes[i] = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
||||||
|
break
|
||||||
|
elif i == len(changes) - 1:
|
||||||
|
# Launchpad-Bugs-Fixed entry does not exist in changes file
|
||||||
|
line = "Launchpad-Bugs-Fixed: %s" % (" ".join(bugs))
|
||||||
|
changes.append(line)
|
||||||
|
|
||||||
|
return "\n".join(changes + [""])
|
||||||
|
|
||||||
|
def sync_dsc(dscurl, debian_dist, release, uploader, bugs, keyid=None, verbose=False):
|
||||||
assert dscurl.endswith(".dsc")
|
assert dscurl.endswith(".dsc")
|
||||||
dscname = os.path.basename(dscurl)
|
dscname = os.path.basename(dscurl)
|
||||||
basepath = os.path.dirname(dscurl)
|
basepath = os.path.dirname(dscurl)
|
||||||
@ -172,6 +191,10 @@ def sync_dsc(dscurl, debian_dist, release, uploader, keyid=None, verbose=False):
|
|||||||
print " ".join(cmd) + " > ../" + changes_file
|
print " ".join(cmd) + " > ../" + changes_file
|
||||||
changes = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
|
changes = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
|
||||||
|
|
||||||
|
# Add additional bug numbers
|
||||||
|
if len(bugs) > 0:
|
||||||
|
changes = add_fixed_bugs(changes, bugs, verbose)
|
||||||
|
|
||||||
# remove extracted (temporary) files
|
# remove extracted (temporary) files
|
||||||
os.chdir('..')
|
os.chdir('..')
|
||||||
shutil.rmtree(directory, True)
|
shutil.rmtree(directory, True)
|
||||||
@ -241,6 +264,9 @@ if __name__ == "__main__":
|
|||||||
default = os.environ["DEBFULLNAME"] + " <" + os.environ["DEBEMAIL"] + ">")
|
default = os.environ["DEBFULLNAME"] + " <" + os.environ["DEBEMAIL"] + ">")
|
||||||
parser.add_option("-k", "--key", dest="keyid",
|
parser.add_option("-k", "--key", dest="keyid",
|
||||||
help="Specify the key ID to be used for signing.", default=None)
|
help="Specify the key ID to be used for signing.", default=None)
|
||||||
|
parser.add_option("-b", "--bug", metavar="BUG",
|
||||||
|
help="Mark a Launchpad bug as being fixed by this upload",
|
||||||
|
dest="bugs", action="append", default=list())
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
@ -251,6 +277,12 @@ if __name__ == "__main__":
|
|||||||
print >> sys.stderr, script_name + ": Error: Multiple .dsc URLs/paths or package names specified: " + ", ".join(args)
|
print >> sys.stderr, script_name + ": Error: Multiple .dsc URLs/paths or package names specified: " + ", ".join(args)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
invalid_bug_numbers = filter(lambda x: not x.isdigit(), options.bugs)
|
||||||
|
if len(invalid_bug_numbers) > 0:
|
||||||
|
print >> sys.stderr, "%s: Error: Invalid bug number(s) specified: %s" % \
|
||||||
|
(script_name, ", ".join(invalid_bug_numbers))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if options.release is None:
|
if options.release is None:
|
||||||
launchpad = get_launchpad("ubuntu-dev-tools")
|
launchpad = get_launchpad("ubuntu-dev-tools")
|
||||||
options.release = launchpad.distributions["ubuntu"].current_series.name
|
options.release = launchpad.distributions["ubuntu"].current_series.name
|
||||||
@ -264,4 +296,4 @@ if __name__ == "__main__":
|
|||||||
if options.verbose:
|
if options.verbose:
|
||||||
print ".dsc url: " + dscurl
|
print ".dsc url: " + dscurl
|
||||||
sync_dsc(dscurl, options.dist, options.release, options.uploader,
|
sync_dsc(dscurl, options.dist, options.release, options.uploader,
|
||||||
options.keyid, options.verbose)
|
options.bugs, options.keyid, options.verbose)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user