diff options
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | sh/ccp | 62 |
2 files changed, 63 insertions, 1 deletions
@@ -7,7 +7,7 @@ # For a command not to echo itself, prefix @ to the command # https://unix.stackexchange.com/a/740226/459013 -SH = alarm backlight bell ccgp cfg chmodef curlqb dateft dirnameall gita gitfork gitmetap gitmetar gitpu grrc il lastarg loop lsp mll mmi mpra mpva mpvy mvln mvtr mvtu news o orgext pa pq px qg qw rate reco rfp sbar ta time-uuid topa upd vinfo wh wtr xmq prp vip vpn dnd cgm ggm +SH = alarm backlight bell ccgp cfg chmodef curlqb dateft dirnameall gita gitfork gitmetap gitmetar gitpu grrc il lastarg loop lsp mll mmi mpra mpva mpvy mvln mvtr mvtu news o orgext pa pq px qg qw rate reco rfp sbar ta time-uuid topa upd vinfo wh wtr xmq prp vip vpn dnd cgm ggm ccp PACMAN_HOOKS = setcap-intel_gpu_top.hook setcap-iotop-c.hook setcap-nethogs.hook PREFIX = /usr/local @@ -0,0 +1,62 @@ +#!/bin/sh +# Cfg git Cherry Pick interactive helper + +ssh pp 'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing' + +cd "$HOME/programs/config_local_arch" || exit 1 + +# https://www.shellcheck.net/wiki/SC2095 +# ssh may swallow stdin, use read need file descriptor workaround or ssh disable stdin +# I choose to use for ... in ... alternative instead +for branch in $(git branch | awk '{print ($1=="*")?$2:$1}'); do + if [ "$branch" != master ]; then + echo "sshing to server $branch..." + # note need \$ else it will run cfg on current computer instead of remote server + ssh -t "$branch" "[ \"\$(cfg -l rev-list origin/$branch..HEAD)\" ] && cfg -l push" + fi + git checkout "$branch" + git pull +done + +git checkout master + +< "$XDG_DATA_HOME/mydata/cfgl_cherry_picked" read -r picked +for commit in $(git rev-list --reverse "$picked..HEAD"); do + git show "$commit" + printf 'Enter branch name to cherry pick this commit: (a for all, enter to skip)\n' + read -r branch_pick + if [ "$branch_pick" = a ]; then + # !/master/ to not cherry pick to master branch + git branch | awk '!/master/{print ($1=="*")?$2:$1}' | while read -r branch; do + git checkout "$branch" + git cherry-pick "$commit" + git status + # wait to check if git status if good or need manual intervention + #echo 'Enter to continue.' + # place holder var a because POSIX read no var is undefined + #read a + done + elif [ "$branch_pick" ]; then + while [ "$branch_pick" ]; do + git checkout "$branch_pick" + git cherry-pick "$commit" + git status + echo 'Enter branch name to cherry pick this commit: (enter to skip)' + read -r branch_pick + done + fi +done + +cp "$XDG_DATA_HOME/mydata/cfgl_cherry_picked" "$XDG_DATA_HOME/mydata/cfgl_cherry_picked.bak" +git checkout master +git rev-parse HEAD > "$XDG_DATA_HOME/mydata/cfgl_cherry_picked" + +# !/master/ to not ssh to master +for branch in $(git branch | awk '!/master/{print ($1=="*")?$2:$1}'); do + git checkout "$branch" + git push + echo "sshing to server $branch..." + ssh -t "$branch" 'cfg -l pull; cfg -lM; cfg -l status' +done + +ssh pp 'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type suspend' |