From c6733efa44583d171635149b4c9e497332a5ab71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Sun, 10 Jun 2018 17:32:33 +0200 Subject: Enhance cci script --- .zsh/functions/cci | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.zsh/functions/cci b/.zsh/functions/cci index b4af773..c581f8a 100644 --- a/.zsh/functions/cci +++ b/.zsh/functions/cci @@ -1,5 +1,9 @@ # Commit a new config change # Works only for simple cases +emulate -L zsh + +setopt err_return + ask () { echo -n ${fg_bold[white]}"Is this ok? [y/n] "${reset_color} @@ -18,12 +22,7 @@ log () echo ${fg_bold[white]}">> $1"${reset_color} } -TRAPEXIT () { - # cleanup - unfunction ask log -} - # ignore a -m [[ $1 == "-m" ]] && shift @@ -34,12 +33,10 @@ fi local message=$1 local tok=__cci__ -local stg_v=$(python2 -c 'from stgit.builtin_version import version; print(version)') - -# bail out on errors with the python thing -(( $? )) && return +local stg_v && stg_v=$(python2 -c 'from stgit.builtin_version import version; print(version)') pushd -q ~ +{ local indexed="$(config status --porcelain | grep -v '^ ')" @@ -73,13 +70,13 @@ if [[ -z $(cstg files) ]]; then fi log "Committing" -cstg commit $tok || return +cstg commit $tok # from 0.16 onwards stg repushes the patches ... pop them again # this is needed to make the `config push` work if is-at-least 0.16 $stg_v; then log "Popping patches, stg thought it had to re-apply" - cstg pop --all --keep || return + cstg pop --all --keep fi if [[ -n $(cstg series --applied) ]]; then @@ -90,13 +87,13 @@ if [[ -n $(cstg series --applied) ]]; then fi log "Pushing to remote" -config push || return +config push log "Re-apply patches" -cstg push --all --keep || return +cstg push --all --keep log "Done" - -popd -q +} always { popd -q } +} always { unfunction ask log } # vim: ft=zsh -- cgit v1.2.3