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

update status of forwared bugs for github



Hey,

I created a python script to check the status of forwarded bugs to github for 
a given source package and sets the "fixed-upstream" tag. My plan is, that 
this script will be available also for other devs and or maybe part of an 
automatic sync. I only checked it for two packages (owncloud and owncloud-
client). Do you know a package where it can be fits in?

Regads,

sandro

PS: I'm not subscribed to the debian-qa list
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Script to check the status of forwared bugs to github
# Copyright 2014 Sandro Knauß <bugs@sandroknauss.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


"""
checks the status of all to github forwared bugs of a src package.

usage: githubUpdate.py <src>

needs python-debianbts to be installed

Copyright: 2014 Sandro Knauß <bugs@sandroknauss.de>
License: GPL v2+
Version: 0.1
"""

import json
import re
import subprocess
try:
    from urllib.request import urlopen
except ImportError:
    from urllib import urlopen
import debianbts

reGithubIssue=re.compile('^http(s)?://github.com/(?P<repo>.*)/issues/(?P<issue>[0-9]+)$')

def isGithubIssue(url):
    """test if the url is a valid github url"""
    return reGithubIssue.match(url) != None

def githubIssue(url):
    """returns a github issue for a issue url

    f.ex: githubIssue("https://github.com/owncloud/mirall/issues/2123";)

    the dict is described here: https://developer.github.com/v3/issues/
    """
    m = reGithubIssue.match(url)
    repo = m.group("repo")
    issue = int(m.group("issue"))
    url = "https://api.github.com/repos/%s/issues/%i"%(repo,issue)
    issue = json.loads(urlopen(url).read())
    return issue

def setFixedUpstream(src):
    """checks the upstream status of forwareded github bugs for a src package
    set fixed-upstream bug, if upstream bug is closed after asking the user.
    """
    bug_nums = debianbts.get_bugs('src', src,'status', 'forwarded')
    print("found %i forwarded bugs for %s" %(len(bug_nums), src))
    bugs = debianbts.get_status(bug_nums)
    for bug in bugs:
        if not bug.done \
                and "fixed-upstream" not in bug.tags \
                and "wontfix" not in bug.tags \
                and isGithubIssue(bug.forwarded):
            issue = githubIssue(bug.forwarded)
            if issue['state'] == 'closed':
                print("%i is closed upstream (%s)" %(bug.bug_num,bug.forwarded))
                i = input('should fixed-upstream tag been set to %s[Y/n]: '%(bug.bug_num))
                if i.strip().lower() == 'y' or i == "":
                    ret = subprocess.call(['bts','tags',bug.bug_num, '+fixed-upstream'])
                    if ret == 0:
                        print("set fixed-upstream for %i"%(bug.bug_num))

if __name__=="__main__":
    import sys
    setFixedUpstream(sys.argv[1])

Reply to: