[Gluster-devel] automating straightforward backports

Pranith Kumar Karampuri pkarampu at redhat.com
Thu Oct 27 03:00:07 UTC 2016


hi,
     Nowadays I am seeing quite a few patches are straightforward backports
from master. But if I follow the process it generally takes around 10
minutes to complete porting each patch. I was wondering if anyone else
looked into automating this. Yesterday I had to backport
http://review.gluster.org/15728 to 3.9, 3.8, 3.7. So I finally took some
time to automate portions of the workflow. I want to exchange ideas you may
be using to achieve the same.

Here is how I automated portions:
1) Cloning bug to different branches:
     Not automated: It seems like bugzilla CLI doesn't allow cloning of the
bug :-(. Anyone knows if we can write a script which interacts with the
website to achieve this?

2) Porting the patch to the branches: Wrote the following script which will
do the porting adding prefix " >" to the commit-headers
===================================================
⚡ cat ../backport.sh
#!/bin/bash
#launch it like this: BRANCHES="3.9 3.8 3.7" ./backport.sh
<branch-name-prefix> <commit-hash-to-be-backported>

prefix=$1
shift
commit=$1
shift

function add_prefix_to_commit_headers {
#We have the habit of adding ' >' for the commit headers
        for i in BUG Change-Id Signed-off-by Reviewed-on Smoke
NetBSD-regression Reviewed-by CentOS-regression; do sed -i -e "s/^$i:/
>$i:/" commit-msg; done
}

function form_commit_msg {
#Get the commit message out of the commit
        local commit=$1
        git log --format=%B -n 1 $commit > commit-msg
}

function main {
        cur_branch=$(git rev-parse --abbrev-ref HEAD)
        form_commit_msg $commit
        add_prefix_to_commit_headers;
        rm -f branches;
        for i in $BRANCHES; do cp commit-msg ${i}-commit-msg && git
checkout -b ${prefix}-${i} origin/release-${i} > /dev/null && git
cherry-pick $commit && git commit -s --amend -F ${i}-commit-msg && echo
${prefix}-${i} >> branches; done
        git checkout $cur_branch
}

main
===================================================

3) Adding reviewers, triggering regressions, smoke:
     I have been looking around for good gerrit-cli, at the moment, I am
happy with the gerrit CLI which is installed through npm. So you need to
first install npm on your box and then do 'npm install gerrit'
     Go to the branch from where we did the commit and do:
        # gerrit assign xhernandez at datalab.es - this will add Xavi as
reviewer for the patch that I just committed.
        # gerrit comment "recheck smoke"
        # gerrit comment "recheck centos"
        # gerrit comment "recheck netbsd"

4) I am yet to look into bugzilla cli to come up with the command to move
the bugs into POST, but may be Niels has it at his fingertips?

Main pain point has been cloning the bugs. If we have an automated way to
clone the bug to different branches. The script at 2) can be modified to
add all the steps.
If we can clone the bug and get the bz of the cloned bug, then we can add
"BUG: <bz>" to the commit-message and launch rfc.sh which won't prompt for
anything. We can auto answer coding-guidelines script by launching "yes |
rfc.sh" if we really want to.

PS: The script is something I hacked together for one time use yesterday.
Not something I guessed I would send a mail about today so it is not all
that good looking. Just got the job done yesterday.

-- 
Pranith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gluster.org/pipermail/gluster-devel/attachments/20161027/948757a8/attachment-0001.html>


More information about the Gluster-devel mailing list