Changed existence tests in upload, minor changes in update

Change-Id: Ic79123eb2fdf9c8a42693c2fbc9bfe608e3be192
diff --git a/github-update b/github-update
index 8765a0f..978b22c 100755
--- a/github-update
+++ b/github-update
@@ -6,14 +6,14 @@
 ##
 ##############################################################################
 
-#replace with auth token for google-automerger GitHub account
+##replace with auth token for google-automerger GitHub account
 TOKEN=herpderp
 
-#make temporary dir to pull code into - delete at end.
+##make temporary dir to pull code into - delete at end.
 mkdir github-temp
 cd github-temp
 
-#iterate through samples
+##iterate through samples
 for i in $(ls ../prebuilts/gradle);
 
 
@@ -21,28 +21,26 @@
 #foo="ActionBarCompat-Basic"
 #foo="ActionBarCompat-Basic herpderp"
 #foo="ActionBarCompat-Basic ActionBarCompat-ListPopupMenu"
+#foo="MediaBrowserService MessagingService"
 #for i in $foo;
 
 do
-#echo $i
+echo "
+$i"
 
 URL=https://github.com/googlesamples/android-$i
 
 result=$(curl -o /dev/null --silent --head --write-out '%{http_code}' "$URL")
 #echo "$result $URL"
 
-#git clone https://github.com/googlesamples/android-$i.git
-
- #checking to see if they're in the list
+##checking to see if the repo exists
 if [ "$result" != "200" ]; then
-   echo "
-Cannot access repo for $i, it may not exist yet" 
+   echo "Cannot access repo for $i, it may not exist yet"
 else
-   echo "
-Updating repo for $i"
+   echo "Updating repo for $i"
 
 git clone $URL.git
-#check to make sure it worked and the folder is there
+##check to make sure it worked and the folder is there
 if [ -d "android-$i" ]; then
    rsync -az --delete --exclude '*.git' ../prebuilts/gradle/$i/ ./android-$i/
 
@@ -66,6 +64,6 @@
 fi
 done
 
-#cleanup
+##cleanup
 cd ..
 rm -rf ./github-temp
diff --git a/github-upload b/github-upload
index a1440a5..4326a7a 100755
--- a/github-upload
+++ b/github-upload
@@ -6,29 +6,34 @@
 ##
 ##############################################################################
 
-#replace with auth token for google-automerger GitHub account
-TOKEN=herpderp 
+##replace with auth token for google-automerger GitHub account
+TOKEN=herpderp
 
-#get list of existing GH repos
-EXISTING=`curl -s https://api.github.com/users/googlesamples/repos  | grep full_name`
+##iterate through samples
 
-#iterate through samples
 cd ./prebuilts/gradle
-
 for i in $(ls);
 
 ##for testing
 #foo="ActionBarCompat-Basic"
-#foo="ActionBarCompat-Basic ActionBarCompat-ListPopupMenu"
+#foo="ActionBarCompat-Basic ActionBarCompat-ListPopupMenu FooBar"
+#foo="ActionBarCompat-Basic Notifications"
 #for i in $foo;
 
 do
-echo $i
- #checking to see if they're in the list
- if [[ "$EXISTING" =~ "$i" ]]; then
+echo "
+$i"
+
+URL=https://github.com/googlesamples/android-$i
+
+result=$(curl -o /dev/null --silent --head --write-out '%{http_code}' "$URL")
+#echo "$result $URL"
+
+##checking to see if the repo already exists
+if [ "$result" != "404" ]; then
    echo "$i already exists as a repo"
  else
-   echo "A repo for $i does not exist yet" 
+   echo "A repo for $i does not exist yet"
 
 repoName="googlesamples/android-$i"
 
@@ -40,9 +45,11 @@
 CREATE="curl -H 'Authorization: token '$TOKEN \
      -d '{\"name\":\"android-'$i'\", \"team_id\":889859}' \
      https://api.github.com/orgs/googlesamples/repos"
+
 #echo "
 #Create Script:
 #"$CREATE
+
 eval $CREATE
 
 #add secondary team permissions (robots)
@@ -50,9 +57,11 @@
 -H 'Authorization: token '$TOKEN \
 -H 'Content-Length: 0' \
 https://api.github.com/teams/889856/repos/$repoName"
+
 #echo "
 #Add Team Robots:
 #"$ADDTEAM
+
 eval $ADDTEAM