diff options
Diffstat (limited to '')
-rw-r--r-- | .zsh/functions/cci | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/.zsh/functions/cci b/.zsh/functions/cci index 0cd6feb..b03666e 100644 --- a/.zsh/functions/cci +++ b/.zsh/functions/cci @@ -1,6 +1,6 @@ # Commit a new config change # Works only for simple cases -_ask_$0 () +ask () { echo -n ${fg_bold[white]}"Is this ok? [y/n] "${reset_color} @@ -13,7 +13,7 @@ _ask_$0 () fi } -_echo_$0 () +log () { echo ${fg_bold[white]}">> $1"${reset_color} } @@ -35,24 +35,24 @@ pushd -q ~ local indexed="$(config status --porcelain | grep -v '^ ')" if [[ -n $indexed ]]; then - _echo_$0 "Stuff in index -- only commiting this" + log "Stuff in index -- only commiting this" echo "$indexed" - _ask_$0 || return 2 + ask || return 2 else - _echo_$0 "Nothing in index -- commiting everything which has changed" + log "Nothing in index -- commiting everything which has changed" echo "$(config status)" - _ask_$0 || return 2 + ask || return 2 config add -u fi cstg diff -O --cached -_ask_$0 || return 2 +ask || return 2 -_echo_$0 "Creating new patch" +log "Creating new patch" cstg new $tok -m "$message" -_echo_$0 "Refreshing" +log "Refreshing" cstg refresh -i if [[ -z $(cstg files) ]]; then @@ -63,13 +63,13 @@ if [[ -z $(cstg files) ]]; then return 3 fi -_echo_$0 "Committing" +log "Committing" cstg commit $tok || return # 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 - _echo_$0 "Popping patches, stg thought it had to re-apply" + log "Popping patches, stg thought it had to re-apply" cstg pop -a -k || return fi @@ -80,14 +80,17 @@ if [[ -n $(cstg series --applied) ]]; then return 4 fi -_echo_$0 "Pushing to remote" +log "Pushing to remote" config push || return -_echo_$0 "Re-apply patches" +log "Re-apply patches" cstg push -a -k || return -_echo_$0 "Done" +log "Done" popd -q +# cleanup +unfunction ask log + # vim: ft=zsh |