Browse code

another attempt at reclone which preserves existing git object dir

Jesse Andrews authored on 2011/10/25 10:42:11
Showing 1 changed files
... ...
@@ -302,20 +302,27 @@ sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
302 302
 # be owned by the installation user, we create the directory and change the
303 303
 # ownership to the proper user.
304 304
 function git_clone {
305
-    # if there is an existing checkout, move it out of the way
306
-    if [[ "$RECLONE" == "yes" ]]; then
307
-        # FIXME(ja): if we were smarter we could speed up RECLONE by
308
-        # using the old git repo as the basis of our new clone...
309
-        if [ -d $2 ]; then
310
-            mv $2 /tmp/stack.`date +%s`
311
-        fi
312
-    fi
313 305
 
306
+    # do a full clone only if the directory doesn't exist
314 307
     if [ ! -d $2 ]; then
315 308
         git clone $1 $2
316 309
         cd $2
317 310
         # This checkout syntax works for both branches and tags
318 311
         git checkout $3
312
+    elif [[ "$RECLONE" == "yes" ]]; then
313
+        # if it does exist then simulate what clone does if asked to RECLONE
314
+        cd $2
315
+        # set the url to pull from and fetch
316
+        git remote set-url origin $1
317
+        git fetch origin
318
+        # if we don't delete the local content, then our system has pyc files 
319
+        # from the previous branch leading to breakage (due to the py files 
320
+        # having older timestamps than our pyc, so python thinks the pyc files
321
+        # are correct using them)
322
+        rm -rf *
323
+        git checkout -f origin/$3
324
+        git branch -D $3
325
+        git checkout -b $3
319 326
     fi
320 327
 }
321 328