diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-04-20 16:56:52 -0700 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-04-20 16:56:52 -0700 |
commit | a059d13a01b693493140e72ae109cbb7d89ae647 (patch) | |
tree | 9ffb13bb6bd3cd7f65113d51bea48acfc787cf58 /sh | |
parent | bfa81b86af0a20ffbc7ddb32c9c65a2d2fa50b03 (diff) |
refactor: ccp use var to store all branch names
Diffstat (limited to 'sh')
-rwxr-xr-x | sh/ccp | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -4,11 +4,13 @@ ssh pp 'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing' cd "$HOME/programs/config_local_arch" || exit 1 +all_branch="$(git branch | awk '{print ($1=="*")?$2:$1}')" +all_branch_no_master="$(echo "$all_branch" | grep -v master)" # https://www.shellcheck.net/wiki/SC2095 # ssh may swallow stdin, use read need file descriptor workaround or ssh disable stdin # so I choose to use for instead of `... | while read ...` -for branch in $(git branch | awk '{print ($1=="*")?$2:$1}'); do +for branch in $all_branch; do if [ "$branch" != master ]; then echo "sshing to server $branch..." # note need \$ else it will run cfg on current computer instead of remote server @@ -27,8 +29,7 @@ for commit in $(git rev-list --reverse "$picked..HEAD"); do (a for all, space to seperate multiple branches, enter to skip)\n' read -r branch_pick if [ "$branch_pick" = a ]; then - # !/master/ to not cherry pick to master branch - branch_pick="$(git branch | awk '!/master/{print ($1=="*")?$2:$1}')" + branch_pick="$all_branch_no_master" fi for branch in $branch_pick; do git checkout "$branch" @@ -41,8 +42,7 @@ cp "$XDG_DATA_HOME/mydata/cfgl_cherry_picked" "$XDG_DATA_HOME/mydata/cfgl_cherry 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 +for branch in $all_branch_no_master; do git checkout "$branch" git push echo "sshing to server $branch..." |