-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from hwixley/feature/cli-auto-update-toggle
CLI Auto-update toggle
- Loading branch information
Showing
3 changed files
with
34 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,34 +16,30 @@ sys sys | |
source $WYX_DIR/src/classes/lib/lib.h | ||
lib lib | ||
|
||
branch="" | ||
if git rev-parse --git-dir > /dev/null 2>&1; then | ||
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | ||
fi | ||
remote=$(git config --get remote.origin.url | sed 's/.*\/\([^ ]*\/[^.]*\).*/\1/') | ||
repo_url=${remote#"[email protected]:"} | ||
repo_url=${repo_url%".git"} | ||
|
||
wyx_git_branch="" | ||
|
||
# AUTO UPDATE CLI | ||
|
||
pull() { | ||
if [ "$1" != "$branch" ]; then | ||
git checkout "$1" | ||
if [ "$1" != "$wyx_git_branch" ]; then | ||
git checkout "$1" || return 1 | ||
fi | ||
git pull origin "$1" | ||
git pull origin "$1" || return 1 | ||
} | ||
|
||
wyx_update() { | ||
if ! grep -q "WYX_GIT_AUTO_UPDATE=true" "${WYX_DATA_DIR}/.env" ; then | ||
sys.log.warn "Auto update disabled" && echo "" | ||
return 1 | ||
fi | ||
sys.log.info "Checking for updates..." | ||
|
||
current_dir=$(pwd) | ||
cd "$WYX_DIR" || return 1 | ||
repo_branch="" | ||
if git rev-parse --git-dir > /dev/null 2>&1; then | ||
repo_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | ||
wyx_git_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') | ||
fi | ||
if [ "$repo_branch" != "master" ]; then | ||
if [ "$wyx_git_branch" != "master" ]; then | ||
sys.log.warn "Not on master branch, skipping update" && echo "" | ||
cd "$current_dir" || return 1 | ||
return 1 | ||
|
@@ -59,7 +55,7 @@ wyx_update() { | |
sys.log.info "Up-to-date" | ||
elif [ "$LOCAL" = "$BASE" ]; then | ||
sys.log.info "Updating..." | ||
pull "$branch" | ||
pull "$wyx_git_branch" | ||
elif [ "$REMOTE" = "$BASE" ]; then | ||
echo "Need to push" | ||
else | ||
|