#!/bin/csh -f # gitsync # ----------------------------------------------------------------------------- # C shell script to sync local files and Git repo w/remote Git repo. # ----------------------------------------------------------------------------- # Revision History: # $Log$ # ----------------------------------------------------------------------------- # Moved from root to local so it will be backed up. #set backup_dir = "/$PWD:t.old" set backup_dir = "$PWD.old" echo "===================================================================" echo "Removing generated files to simplify the compare..." pause echo "===================================================================" echo rm -rfv ${backup_dir}/.git rm -rfv ${backup_dir}/.git #??rm -rfv ${backup_dir}/.settings #??rm -rfv ${backup_dir}/bin #??rm -rfv ${backup_dir}/target echo "===================================================================" echo "" echo "===================================================================" echo "Review changes to local directory..." pause echo "===================================================================" echo windiff . ${backup_dir} windiff . ${backup_dir} echo "===================================================================" echo "" while (1 == 1) echo "===================================================================" echo "Current Git status..." echo "===================================================================" echo git status git status echo "===================================================================" echo "" set prompt = "More changes to review/add/commit (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Running gitx for adds and commits..." echo "===================================================================" echo gitx gitx echo "===================================================================" else echo "" break endif echo "" # Old way. Using git add -i and git commit instead of gitx # if ($proceed == "y") then # echo "===================================================================" # echo "Adding/updating staged files for Git..." # echo "===================================================================" # echo git add -i # git add -i # echo "===================================================================" # else # echo "" # break # endif # echo "" # # set prompt = "Commit these changes (y/n)? " # set proceed = `promptloop "${prompt}" y n` # if ($proceed == "y") then # echo "===================================================================" # echo "Committing staged files to Git..." # echo "===================================================================" # echo git commit # git commit # echo "===================================================================" # endif # echo "" end echo "===================================================================" echo "Pulling (dry run) from Git and reviewing changes..." echo "===================================================================" echo gitpulldryrun gitpulldryrun echo "===================================================================" echo "" echo "===================================================================" echo "Pulling from Git and reviewing changes..." echo "===================================================================" # Blank line before first prompt of gitpullreview, and no need for line # of "===" afterwards since it does its own seamlessly. echo gitpullreview; echo "" gitpullreview while (1 == 1) echo "===================================================================" echo "Current Git status..." echo "===================================================================" echo git status git status echo "===================================================================" echo "" hhlver set prompt = "More changes to add/commit, especially version number (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Running gitx for adds and commits..." echo "===================================================================" echo gitx gitx echo "===================================================================" else echo "" break endif echo "" end set prompt = "Add git tag (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Adding git tag..." echo "===================================================================" echo -n "Git tag (like 2.6.587)? " > /dev/tty set tag=$< echo git tag $tag git tag $tag echo "===================================================================" endif echo "" set prompt = "Do a git push --dry-run (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Git push dry-run..." echo "===================================================================" # Have to push tags separately from commits. Otherwise --tags makes # it push only the tags. echo git push --dry-run git push --dry-run echo git push --dry-run --tags git push --dry-run --tags endif echo "===================================================================" echo "" set prompt = "Do a git push (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Git push..." echo "===================================================================" # Have to push tags separately from commits. Otherwise --tags makes # it push only the tags. echo git push git push echo git push --tags git push --tags endif echo "===================================================================" echo "" set prompt = "Do it all again to see if anything is new in Git (y/n)? " set proceed = `promptloop "${prompt}" y n` if ($proceed == "y") then echo "===================================================================" echo "Repeat..." echo "===================================================================" echo gitsync gitsync else echo "===================================================================" echo "Done!" echo "===================================================================" echo "" endif