<div dir="ltr"><div><div><div><div><div><div><div><div>hi,<br></div>     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 <a href="http://review.gluster.org/15728">http://review.gluster.org/15728</a> 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.<br><br></div>Here is how I automated portions:<br></div>1) Cloning bug to different branches:<br></div>     Not automated: It seems like bugzilla CLI doesn&#39;t allow cloning of the bug :-(. Anyone knows if we can write a script which interacts with the website to achieve this?<br><br></div>2) Porting the patch to the branches: Wrote the following script which will do the porting adding prefix &quot; &gt;&quot; to the commit-headers<br>===================================================<br>⚡ cat ../backport.sh <br>#!/bin/bash<br>#launch it like this: BRANCHES=&quot;3.9 3.8 3.7&quot; ./backport.sh &lt;branch-name-prefix&gt; &lt;commit-hash-to-be-backported&gt;<br><br>prefix=$1<br>shift<br>commit=$1<br>shift<br><br>function add_prefix_to_commit_headers {<br>#We have the habit of adding &#39; &gt;&#39; for the commit headers<br>        for i in BUG Change-Id Signed-off-by Reviewed-on Smoke NetBSD-regression Reviewed-by CentOS-regression; do sed -i -e &quot;s/^$i:/ &gt;$i:/&quot; commit-msg; done<br>}<br><br>function form_commit_msg {<br>#Get the commit message out of the commit<br>        local commit=$1<br>        git log --format=%B -n 1 $commit &gt; commit-msg<br>}<br><br>function main {<br>        cur_branch=$(git rev-parse --abbrev-ref HEAD)<br>        form_commit_msg $commit<br>        add_prefix_to_commit_headers;<br>        rm -f branches;<br>        for i in $BRANCHES; do cp commit-msg ${i}-commit-msg &amp;&amp; git checkout -b ${prefix}-${i} origin/release-${i} &gt; /dev/null &amp;&amp; git cherry-pick $commit &amp;&amp; git commit -s --amend -F ${i}-commit-msg &amp;&amp; echo ${prefix}-${i} &gt;&gt; branches; done<br>        git checkout $cur_branch<br>}<br><br>main<br>===================================================<br><br></div>3) Adding reviewers, triggering regressions, smoke:<br></div>     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 &#39;npm install gerrit&#39;<br></div>     Go to the branch from where we did the commit and do:<br>        # gerrit assign <a href="mailto:xhernandez@datalab.es">xhernandez@datalab.es</a> - this will add Xavi as reviewer for the patch that I just committed.<br>        # gerrit comment &quot;recheck smoke&quot;<br>        # gerrit comment &quot;recheck centos&quot;<div><div><div><div><div><div><div><div><div><div>        # gerrit comment &quot;recheck netbsd&quot;<br><br></div><div>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?<br><br></div><div>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.<br></div><div>If we can clone the bug and get the bz of the cloned bug, then we can add &quot;BUG: &lt;bz&gt;&quot; to the commit-message and launch rfc.sh which won&#39;t prompt for anything. We can auto answer coding-guidelines script by launching &quot;yes | rfc.sh&quot; if we really want to.<br></div><div><br></div><div>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.<br><br></div><div>-- <br><div class="gmail_signature"><div dir="ltr">Pranith<br></div></div>
</div></div></div></div></div></div></div></div></div></div></div>