[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

T.
-- 
Thomas Viehmann, http://thomas.viehmann.net/
#!/usr/bin/python
import sys, rfc822, ldap
from apt_listchanges import ttyconfirm

def parse_changes(changes):
    chg_fd = open(changes)
    check = chg_fd.read(5)
    if check != '-----':
        chg_fd.seek(0)
    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:
        chg_fd.readline()
    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)
 l.simple_bind()
 resid = l.search("dc=current,dc=bugs,dc=debian,dc=org",
		 ldap.SCOPE_SUBTREE,
		 "(|%s)"%(''.join(map(lambda x: "(debbugsID=%d)"%x, closedbugs))),
		 ["debbugsPackage","debbugsID","debbugsTitle"])
 res = []
 r = l.result(resid, 0)
 while r and r[1]:
   res.append(r[1][0][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'])),
      otherpkgsbugstouched))
  print "Do you want to continue? [y/N]",
  if sys.stdin.readline()[1:] not in ['y','Y']:
    sys.exit(1)

Reply to: