[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Pkg-octave-devel] Git notifications [was Re: Merging octave-{doc, info, htmldoc}]



Replying to this old message:

* Sébastien Villemot <sebastien@debian.org> [2018-01-07 12:43]:

On Sun, Jan 07, 2018 at 12:39:29PM +0100, Rafael Laboissière wrote:
* Sébastien Villemot <sebastien@debian.org> [2018-01-07 12:35]:

Thanks, I pushed that change.

Just FYI, the dispatch+octave_vcs@tracker.debian.org destination for push notifications worked properly.

Yes, I just saw that, thanks for setting it up.

I noticed that the 3 commits I pushed were merged in a single diff. Your mileage may vary, but I would prefer to have three diffs, to keep the logical split between the commits. Have you seen an option in salsa for that?

I wrote the script attached below for pushing individual commits. I have not checked whether such a script was already available elsewhere.

Rafael
#!/bin/sh

# Copyright (C) 2018  Rafael Laboissiere
#
# git-push-individual-commits: Individual pushes of commits not yet pushed
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script; if not, see <http://www.gnu.org/licenses/>.

prog=${0##*/git-}
usage="Usage: git $prog [-h|-d]"
help="\n\
This script pushes separately each individual commit in the current local\n\
branch that have not yet been pushed into the remote branch of same name.\n\
\n\
It may be useful when pushing into a GitLab remote repository which has the\n\
'Emails on push' integration service activated.  If several commits are\n\
pushed at once, the service will issue a single email message with the\n\
merged diff output.\n\
\n\
Options:\n\
  -h: print this help message and exit
  -d: dry run"

bad_option=
bad_arg=no
do_help=no
dry_run=no

while test $# -gt 0 ; do
    case "$1" in
        -d) dry_run=yes ; shift ;;
        -h) do_help=yes ; shift ;;
        -*) bad_option=$1 ; break ;;
        *) bad_arg=yes; break ;;
    esac
done

croak () {
  case "$1" in
    E) echo "$2" | sed "s;^;$prog:E: ;" 1>&2 ; exit 1 ;;
    I) echo "$2" | sed "s;^;$prog:I: ;" ;;
  esac
}

test $do_help = yes && croak I "$usage\n$help" && exit 0
test $bad_arg = yes && croak E "$usage"
test -n "$bad_option" && croak E "Unknown option $bad_option"

local=$(git branch --contains HEAD | sed 's/^. //')
remote=$(git config --get branch.$local.remote)

test -z "$remote" && croak E "There is no remote branch for local branch $local"

msg_shown=no

for commit in $(git log --reverse --pretty="format:%H" $remote/$local..$local) ; do
    if test $dry_run = yes ; then
        if test $msg_shown = no ; then
            croak I "Dry run"
            msg_shown=yes
        fi
        echo git push $remote $commit:$local
    else
        git push $remote $commit:$local
    fi
done

Reply to: