diff .bashrc @ 334:5b67dd5ce0ba

update virtualenv before upgrading
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 18 Jun 2013 15:44:55 -0700
parents d0f91aad5f84
children 99f8142078c7
line wrap: on
line diff
--- a/.bashrc	Tue Jun 18 14:44:14 2013 -0700
+++ b/.bashrc	Tue Jun 18 15:44:55 2013 -0700
@@ -1,3 +1,7 @@
+#!/bin/bash
+### bash rc file ###
+
+# so
 PROFILE=/etc/profile
 if [ -e "${PROFILE}" ]
 then
@@ -337,8 +341,26 @@
 recreate-venv() {
     # recreate a virtualenv
     VIRTUALENV="virtualenv.py"
+    if ! which ${VIRTUALENV}
+    then
+        return 1
+    fi
+    VENV_PATH=$(which ${VIRTUALENV} &> /dev/null)
+
+    # update virtualenv if possible
+    DIRNAME=$(dirname ${VENV_PATH})
+    if [ -d "${DIRNAME}/.git" ]
+    then
+        cd "${DIRNAME}"
+        git pull
+        cd --
+    fi
+
+
+    # for each virtualenv given...
     for i in $@
     do
+        # ...recreate it...
         ${VIRTUALENV} --clear "${i}"
 
         SRCDIR="${i}"/src