@@ -53,29 +53,44 @@ if [ -d "$CLONE_DIR" ]; then
53
53
echo " Preparing to update $REPO "
54
54
cd $CLONE_DIR
55
55
56
- # Reset the remote URL because the embedded user token may have changed
57
- git remote set-url origin $REPO
56
+ # Make sure the CLONE_DIR folder is a git folder
57
+ if git status & > /dev/null ; then
58
+ # Reset the remote URL because the embedded user token may have changed
59
+ git remote set-url origin $REPO
58
60
59
- echo " Cleaning up the working directory"
60
- git reset -q --hard
61
- git clean -df
62
- git gc
63
- git_retry git remote prune origin
61
+ echo " Cleaning up the working directory"
62
+ git reset -q --hard
63
+ git clean -df
64
+ git gc
65
+ git_retry git remote prune origin
64
66
65
- echo " Fetching the updates from origin"
66
- git_retry git fetch --tags
67
+ echo " Fetching the updates from origin"
68
+ git_retry git fetch --tags
67
69
68
- if [ -n " $REVISION " ]; then
70
+ if [ -n " $REVISION " ]; then
69
71
70
- echo " Updating $REPO to revision $REVISION "
71
- git checkout $REVISION
72
+ echo " Updating $REPO to revision $REVISION "
73
+ git checkout $REVISION
72
74
73
- CURRENT_BRANCH=" ` git branch 2> /dev/null | grep ' ^*' | cut -d' ' -f2-` "
75
+ CURRENT_BRANCH=" ` git branch 2> /dev/null | grep ' ^*' | cut -d' ' -f2-` "
74
76
75
- # If the revision is identical to the current branch we can rebase it with the latest changes. This isn't needed when running detached
76
- if [ " $REVISION " == " $CURRENT_BRANCH " ]; then
77
- echo ' Rebasing current branch $REVISION to latest changes...'
78
- git rebase
77
+ # If the revision is identical to the current branch we can rebase it with the latest changes. This isn't needed when running detached
78
+ if [ " $REVISION " == " $CURRENT_BRANCH " ]; then
79
+ echo ' Rebasing current branch $REVISION to latest changes...'
80
+ git rebase
81
+ fi
82
+ fi
83
+ else
84
+ # The folder already exists but it is not a git repository
85
+ # Clean folder and clone a fresh copy on current directory
86
+ cd ..
87
+ rm -rf $CLONE_DIR
88
+ echo " cloning $REPO "
89
+ git_retry git clone $REPO $CLONE_DIR
90
+ cd $CLONE_DIR
91
+
92
+ if [ -n " $REVISION " ]; then
93
+ git checkout $REVISION
79
94
fi
80
95
fi
81
96
else
0 commit comments