From c63663599897134a8f21a568028980ae3049cc83 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Mon, 3 May 2021 20:42:08 +0200 Subject: [PATCH] further work on git auto save --- .config/custom_functions/git_auto_save.sh | 52 ++++++++++++++++++----- .config/polybar/config.ini | 1 - .xmonad/xmonad.hs | 4 +- 3 files changed, 43 insertions(+), 14 deletions(-) delete mode 120000 .config/polybar/config.ini diff --git a/.config/custom_functions/git_auto_save.sh b/.config/custom_functions/git_auto_save.sh index 5fa1e43..4c64dcf 100644 --- a/.config/custom_functions/git_auto_save.sh +++ b/.config/custom_functions/git_auto_save.sh @@ -15,6 +15,20 @@ function get_current_branch { echo $(git branch | grep "*" | awk '{print $NF}') } +function get_auto_save_branches { + + auto_save_branches_raw=`git branch | grep "git_auto_save" | tail -1 | awk '{print $FN}'` + auto_save_branches=() + for i in "${$auto_save_branches_raw[@]}" + do + echo ${git_auto_save_branches_raw[i]} + #auto_save_branches+=${git_auto_save[i]} + done + + echo $auto_save_branches + +} + function git_auto_save { if [[ $(is_git ".") -ne 0 ]]; then @@ -35,27 +49,35 @@ function git_auto_save { fi # stash changes - git stash + echo "Stashing changes..." + git stash > /dev/null 2>&1 # create new branch - git checkout -b $new_branch_name - git push origin $new_branch_name + echo "Creating new branch $new_branch_name..." + git checkout -b $new_branch_name > /dev/null 2>&1 + git push origin $new_branch_name > /dev/null 2>&1 # apply stashed changes - git stash apply + echo "Applying stash to new branch..." + git stash apply > /dev/null 2>&1 # add changed files - git add -u + echo "Adding new/changed files..." + git add -u > /dev/null 2>&1 # commit changes - git commit -m "git autosave from $timestamp" + echo "Commiting changes..." + git commit -m "git autosave from $timestamp" > /dev/null 2>&1 # push changes - git push --set-upstream origin $new_branch_name + echo "Pushing changes..." + git push --set-upstream origin $new_branch_name > /dev/null 2>&1 # move back to initial branch - git checkout $current_branch_name + echo "Moving back to previous branch..." + git checkout $current_branch_name > /dev/null 2>&1 + echo "Done." } function remove_auto_save { @@ -64,6 +86,8 @@ function remove_auto_save { echo "Current dir is not a git repository." return 1 fi + + echo "Looking for auto-save branches..." if [[ $1 ]]; then auto_save_branch=$1 @@ -71,12 +95,15 @@ function remove_auto_save { auto_save_branch=`git branch | grep "git_auto_save" | head -1 | awk '{print $FN}'` fi + if [[ ! $auto_save_branch ]]; then echo "No auto-save branch found." return 1 fi auto_save_branch=${auto_save_branch:2} + echo "Auto-save branch found: $auto_save_branch" + current_branch=$(get_current_branch) # if on autosave branch, move to master @@ -86,10 +113,12 @@ function remove_auto_save { fi # remove local branch - git branch -d $auto_save_branch + echo "Deleting local branch..." + git branch -d $auto_save_branch > /dev/null 2>&1 # remove remote branch - git push origin --delete $auto_save_branch + echo "Deleting remote branch..." + git push origin --delete $auto_save_branch > /dev/null 2>&1 return 0 @@ -120,5 +149,6 @@ function remove_all_auto_saves { } function load_last_auto_save { - echo "" + auto_save_branches=$(get_auto_save_branches) + echo $auto_save_branches } diff --git a/.config/polybar/config.ini b/.config/polybar/config.ini deleted file mode 120000 index c0ed933..0000000 --- a/.config/polybar/config.ini +++ /dev/null @@ -1 +0,0 @@ -config.ini##class.arch_desktop \ No newline at end of file diff --git a/.xmonad/xmonad.hs b/.xmonad/xmonad.hs index e1dee1c..abed9af 100644 --- a/.xmonad/xmonad.hs +++ b/.xmonad/xmonad.hs @@ -94,8 +94,8 @@ green = "#859900" -- sizes gap = 10 -topbar = 0 -border = 2 +topbar = 5 +border = 5 prompt = 5 status = 5