[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatic closing of bugs

Hi Matt,

if that would help, I'd include a (n option that allows to) check via
bts2ldap + the attached script into dput.
That'd be less intrusive than changing the behaviour of Closes:, for
better or worse.

Kind regards

Thomas Viehmann, http://thomas.viehmann.net/
import sys, rfc822, ldap
from apt_listchanges import ttyconfirm

def parse_changes(changes):
    chg_fd = open(changes)
    check = chg_fd.read(5)
    if check != '-----':
    else: # found a PGP header, gonna ditch the next 3 lines
        chg_fd.readline() # eat the rest of the line
        chg_fd.readline() # Hash: SHA1
        chg_fd.readline() # empty line
    if not chg_fd.readline().find('Format') != -1:
    changes = rfc822.Message(chg_fd)
    return changes

ch = parse_changes(sys.argv[1])

closedbugs = map(int, ch.get('Closes','').split())
pkgs = ch.get('Binary','').split()+[ch.get('Source','')]

if closedbugs:
 print "Querying ldap..."
 l = ldap.open("bts2ldap.debian.net", 10101)
 resid = l.search("dc=current,dc=bugs,dc=debian,dc=org",
		 "(|%s)"%(''.join(map(lambda x: "(debbugsID=%d)"%x, closedbugs))),
 res = []
 r = l.result(resid, 0)
 while r and r[1]:
   r = l.result(resid, 0)

 otherpkgsbugstouched = filter(lambda a: a['debbugsPackage'][0] not in pkgs, res)
 if otherpkgsbugstouched:
  print 'Changelog closes bugs of other packages:'
  print '  '+'\n  '.join(map(lambda y:
			     ' '.join(map(lambda x: ' '.join(y[x]),['debbugsID','debbugsPackage','debbugsTitle'])),
  print "Do you want to continue? [y/N]",
  if sys.stdin.readline()[1:] not in ['y','Y']:

Reply to: