summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2018-06-10 17:32:33 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2018-06-10 17:32:34 +0200
commitc6733efa44583d171635149b4c9e497332a5ab71 (patch)
treeea7a3bdb746af837582b6da768061bb7b5b05c71
parent98521abd2f038e06d732226f4eb788be607eb862 (diff)
downloaddotfiles-c6733efa44583d171635149b4c9e497332a5ab71.tar.gz
dotfiles-c6733efa44583d171635149b4c9e497332a5ab71.tar.bz2
dotfiles-c6733efa44583d171635149b4c9e497332a5ab71.zip
Enhance cci script
-rw-r--r--.zsh/functions/cci27
1 files 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