Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


On Fri, Apr 03, 2015 at 06:51:32PM +0200, Jan Holesovsky <kendy@collabora.com> wrote:
        + would be good to have 10% as the goal for Linux (Bjoern)
            + that is achievable if people test their commits (Norbert)

I'm attaching two scripts I'm using for a while now, git-breview (as in
git build-check-review) is a wrapper around git-review that also does a
+2 on your change, indicating that you're only submitting the change to
gerrit for build verification. (Ideally sooner or later doing the same
with a simple 'git push' will be possible after tweaking .git/config,
but that's not the case for our gerrit instance ATM.) So you don't have
to go to the web interface and code-review+2 your change manually.

The other one is gerrit-autosubmit that you can run in the root of your
master checkout, it listens on the gerrit event stream and in case your
change gets a verified+1 label, then it submits to the change to master.
So you don't have to wait for the jenkins feedback, if the result is
success, it'll instantly go to master. (I *think* ideally jenkins could
do this itself.)

If others find these scripts useful, then maybe they should be placed in
dev-tools.git.

Just my two cents on making build-verify-on-gerrit a bit less painful
compared to direct pushing to master. :-)

Regards,

Miklos
#!/usr/bin/python
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

import json
import os
import subprocess


def get_config(key):
    sock = subprocess.Popen(["git", "config", "-f", ".gitreview", key], stdout=subprocess.PIPE)
    ret = sock.stdout.readline().strip()
    sock.stdout.close()
    return ret

server = get_config("gerrit.host")
project = get_config("gerrit.project")
branch = get_config("gerrit.defaultbranch")

sock = subprocess.Popen(["ssh", server, "gerrit", "stream-events"], stdout=subprocess.PIPE, 
bufsize=1)

for line in iter(sock.stdout.readline, b''):
    event = json.loads(line)

    if event['type'] != "comment-added":
        continue
    if event['change']['owner']['username'] != os.environ['USER']:
        continue
    if event['change']['project'] != project:
        continue
    if event['change']['branch'] != branch:
        continue
    if 'approvals' not in event.keys():
        continue
    if len([approval for approval in event['approvals'] if approval['type'] == "Verified" and 
approval['value'] == "1"]) != 1:
        continue

    rev = event['patchSet']['revision']
    cmd = "ssh " + server + " gerrit review -s " + rev
    print(cmd)
    os.system(cmd)

sock.communicate()

# vim:set shiftwidth=4 softtabstop=4 expandtab:
#!/usr/bin/env bash
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

if git-review; then
    rev=$(git rev-parse HEAD)
    host=$(git config -f .gitreview gerrit.host)
    ssh $host gerrit review --code-review=2 $rev
fi

# vim:set shiftwidth=4 softtabstop=4 expandtab:

Attachment: signature.asc
Description: Digital signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.