codebuilds icon indicating copy to clipboard operation
codebuilds copied to clipboard

build.sh not re-entrant

Open tangentsoft opened this issue 5 years ago • 0 comments

If the build fails and you retry it after fixing something, it gripes:

Retrieving latest Visual Studio Code sources into [code]
fatal: destination path 'code' already exists and is not an empty directory.

It should detect this condition and just do a git pull in there, not try to re-clone the repo. Trivial patch:

diff --git a/build.sh b/build.sh
index 390f697354..3e9f7749fd 100755
--- a/build.sh
+++ b/build.sh
@@ -5,7 +5,12 @@ echo "Installing NVM and NodeJS";
 . ./setup_nvm.sh;
 
 echo "Retrieving latest Visual Studio Code sources into [code]";
-git clone "https://github.com/Microsoft/vscode.git" code;
+if [ -d code ]
+then
+    ( cd code ; git pull )
+else
+    git clone "https://github.com/Microsoft/vscode.git" code;
+fi
   
 echo "Setting current owner as owner of code folder";
 chown ${USER:=$(/usr/bin/id -run)}:$USER -R code;

By the way, semicolons at the end of lines in shell scripts do nothing useful. :)

tangentsoft avatar May 26 '20 22:05 tangentsoft