Example #1
0
def get_change_list(project, age=None, sort_key=None):

    last_sort_key = False	
    while sort_key != last_sort_key:
        last_sort_key = sort_key
        print(("Getting chages from gerrit - "
              "project: {0}; sortKey: {1}.").format(project, sort_key))
        try:
            changes = gerrit.bulk_query(("--commit-message --comments "
                                     "--current-patch-set --patch-sets "
                                     "--all-approvals --files --dependencies "
                                     "--submit-records limit:100 -- "
                                     "project:{0} resume_sortkey:{1} "
                                     "{2}").format(project, sort_key, 
                                       "-age:{0}".format(age) 
                                         if age else ""))
        except Exception, e:
            print(e)

        for change in changes:
            if 'id' not in change: continue
            print('{3} is {2} in {0} at {1}'.format(
                change['project'], change['sortKey'], change['status'], 
                change['number']))
            change['_id'] = change['id']
            changedb.save(change)
            if 'sortKey' in change:
                sort_key = change['sortKey']
        
	sleep(randint(5, 10))
Example #2
0
def get_unapproved_blueprint_patches(approved_blueprints, invalid_blueprints):
    """Return a list of patches with unapproved blueprints."""
    result = {}  # URL: BP
    gerrit = gerritlib.gerrit.Gerrit("review.openstack.org", "jogo", 29418)
    for patch in gerrit.bulk_query('--commit-message --all-approvals project:openstack/nova status:open'):
        msg = patch.get('commitMessage')
        if msg is None:
            continue
        if is_blocked(patch):
            continue
        bps = get_blueprints(msg)
        if len(bps) > 0:
            for bp in bps:
                if not in_bps_list(bp, approved_blueprints):
                    if in_bps_list(bp, invalid_blueprints):
                        result[patch['url']] = bp
                    else:
                        result[patch['url']] = ("%s (unknown)" % bp)
    return result
Example #3
0
def collect_rechecks(gerrit, days="14"):
    # query only during the last 2 weeks, as that's what ER knows about
    since = int(time.time()) - 24 * 60 * 60 * int(days)
    changes = []
    sortkey = None
    while True:
        query = ("--patch-sets --comments project:^openstack.* "
                 " NOT age:%sd" % days)
        if sortkey:
            query += " resume_sortkey:%s" % sortkey

        data = gerrit.bulk_query(query)
        if len(data) <= 1:
            # means we only have the counter row
            break

        for d in data:
            if 'comments' in d:
                sortkey = d['sortKey']
                comments = d['comments']
                project = d['project']
                for comment in comments:
                    if comment['timestamp'] < since:
                        # bail early if the comment is outside the ER window
                        continue

                    m = re.search('recheck (no bug|bug (\#)?(?P<bugno>\d+))$',
                                  comment['message'])
                    if m:
                        dev = None
                        if 'username' in comment['reviewer']:
                            dev = comment['reviewer']['username']
                        bug = m.group('bugno') or 'no bug'
                        changes.append({
                            'dev': dev,
                            'project': project,
                            'bug': bug,
                            'review': d['url']
                        })
    return changes
Example #4
0
def get_patches(project="nova"):
    filename = "%s-patches.txt" % project
    try:
        with open(filename, "r+b") as f:
            return json.load(f)
    except:
        print "Cache could not load."

    gerrit = gerritlib.gerrit.Gerrit("review.openstack.org", GERRIT_USER, 29418)
    print "Fetching patches..."
    all_patches = []
    all_status = ["open", "abandoned", "merged"]
    for status in all_status:
        result = gerrit.bulk_query('--commit-message project:openstack/%s status:%s' % (project, status))
        all_patches += result
    print len(all_patches)

    with open(filename, 'w+b') as f:
        f.write(json.dumps(all_patches))
        print "Saved to %s" % filename

    return all_patches
def collect_rechecks(gerrit, days="14"):
    # query only during the last 2 weeks, as that's what ER knows about
    since = int(time.time()) - 24 * 60 * 60 * int(days)
    changes = []
    sortkey = None
    while True:
        query = ("--patch-sets --comments project:^openstack.* "
                 " NOT age:%sd" % days)
        if sortkey:
            query += " resume_sortkey:%s" % sortkey

        data = gerrit.bulk_query(query)
        if len(data) <= 1:
            # means we only have the counter row
            break

        for d in data:
            if 'comments' in d:
                sortkey = d['sortKey']
                comments = d['comments']
                project = d['project']
                for comment in comments:
                    if comment['timestamp'] < since:
                        # bail early if the comment is outside the ER window
                        continue

                    m = re.search('recheck (no bug|bug (\#)?(?P<bugno>\d+))$',
                                  comment['message'])
                    if m:
                        dev = None
                        if 'username' in comment['reviewer']:
                            dev = comment['reviewer']['username']
                        bug = m.group('bugno') or 'no bug'
                        changes.append(
                            {'dev': dev,
                             'project': project,
                             'bug': bug,
                             'review': d['url']})
    return changes