diff --git a/.gitignore b/.gitignore index 34403f9..984f248 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ chromedriver.log *.class #Test123 +#test1234 # Package Files # *.jar *.war diff --git a/script/merge_upstream.sh b/script/merge_upstream.sh new file mode 100755 index 0000000..f0b35a0 --- /dev/null +++ b/script/merge_upstream.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Update source code from main repository + +# Pop any stashed changes +unstash() { +if [[ "$stash" =~ "No local changes to save" ]]; then +echo "* No stashed changes, not popping" +else +echo "* Popping stash..." +git stash pop +fi +} + +# Pop any stashed changes and exit +rollback() { +echo +echo "Something went wrong, rolling back" +unstash +exit $1 +} + +# Stash any local change" +echo "* Stash any local changes" +stash=$(git stash) + +remote_upstream="upstream" +remote_upstream_master_branch="master" + +upstream_remote_exists=$(git branch -r --no-color | egrep "$remote_upstream/$remote_upstream_master_branch\$") + +if [ -n "$upstream_remote_exists" ] && [ ! "$upstream_remote_exists" == '' ]; then + echo "* Upstream remote branch exists ....." +else + echo "* Adding upstream remote branch" + git remote add upstream https://github.com/interview-com-ua/website.git +fi + +echo "* Fetching from upstream " +git fetch upstream || rollback $? +echo "* Checkout local master " +git checkout master +echo "* Merge local master and upstream/master" +git merge upstream/master || rollback $? +echo "* Push changes into remote origin/master" +git push origin + +unstash +read -rp "* Done. Press any key to continue..." key diff --git a/script/merge_upstream_windows.sh b/script/merge_upstream_windows.sh new file mode 100644 index 0000000..0ce4742 --- /dev/null +++ b/script/merge_upstream_windows.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Update source code from main repository + +# Pop any stashed changes +unstash() { +if [ "$stash" != "No local changes to save" ]; then +echo "* No stashed changes, not popping" +else +echo "* Popping stash..." +git stash pop +fi +} + +# Pop any stashed changes and exit +rollback() { +echo +echo "Something went wrong, rolling back" +unstash +exit $1 +} + +# Stash any local change" +echo "* Stash any local changes" +stash=$(git stash) + +remote_upstream="upstream" +remote_upstream_master_branch="master" + +upstream_remote_exists=$(git branch -r --no-color | egrep "$remote_upstream/$remote_upstream_master_branch\$") + +if [ -n "$upstream_remote_exists" ] && [ ! "$upstream_remote_exists" == '' ]; then + echo "* Upstream remote branch exists ....." +else + echo "* Adding upstream remote branch" + git remote add upstream https://github.com/interview-com-ua/website.git +fi + +echo "* Fetching from upstream " +git fetch upstream || rollback $? +echo "* Checkout local master " +git checkout master +echo "* Merge local master and upstream/master" +git merge upstream/master || rollback $? +echo "* Push changes into remote origin/master" +#git push origin + +unstash +read -rp "* Done. Press any key to continue..." key