On Thu, Jul 25, 2019 at 08:39:21AM -0700, Ben Pfaff wrote:
> On Thu, Jul 25, 2019 at 11:21:25AM +0300, Ilya Maximets wrote:
> > On 25.07.2019 6:09, Ben Pfaff wrote:
> > > On Wed, Jul 24, 2019 at 08:25:54PM +0300, Ilya Maximets wrote:
> > >> On 24.07.2019 20:05, Ben Pfaff wrote:
> > >>> Signed-off-by: Ben Pfaff <[email protected]>
> > >>> ---
> > >>> Based on an off-lst discussion with Ilya.  This is just my first, 
> > >>> off-hand
> > >>> thought on the topic.  Feedback welcome!
> > >>
> > >> We could also consider suggesting a git hook like that:
> > >> ---
> > >> $ cat .git/hooks/pre-push
> > >> #!/bin/bash
> > >>
> > >> remote=$1
> > >> protected_remote='upstream'
> > >>
> > >> if [ $protected_remote != $remote ]; then exit 0; fi
> > >>
> > >> echo "You're about to push to $protected_remote."
> > >>
> > >> read -p "Do you want to proceed? [y|n] " reply < /dev/tty
> > >> if echo $reply | grep -E '^[Yy]$' > /dev/null; then exit 0; fi
> > >>
> > >> exit 1
> > >> ---
> > > 
> > > Have you tried this?  How does it work for you in practice?
> > 
> > Yes. It works for me.
> > 'exit 1' from the script fails the hook and disallows further push 
> > processing.
> 
> OK.  Do you want to submit a patch?

I've now installed something similar locally.  I wanted to make sure
that my script for automatic crossporting didn't prompt me, so I
modified it to be selective about the branch name:

#!/bin/bash

remote=$1
protected_remote='ovs'

if [ $protected_remote != $remote ]; then exit 0; fi

prompt=no
while read local_ref local_sha1 remote_ref remote_sha1; do
    case $remote_ref in
        refs/heads/master) prompt=yes ;;
    esac
done
if test $prompt = no; then exit 0; fi

echo "You're about to push to a protected branch on $protected_remote."

read -p "Do you want to proceed? [y|n] " reply < /dev/tty
if echo $reply | grep -E '^[Yy]$' > /dev/null; then exit 0; fi

exit 1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to