OSDN Git Service

envsetup: Fix aosp & caf remote
authorluca020400 <luca.stefani.ge1@gmail.com>
Thu, 5 May 2016 19:53:40 +0000 (21:53 +0200)
committerSteve Kondik <steve@cyngn.com>
Sun, 4 Sep 2016 04:47:36 +0000 (21:47 -0700)
Fixes: sed: -e expression #1, char 9: unknown option to `s'

* Return if .git directory is missing and move it on the top
* Update cmremote strings ( match caf/aosp remote )

Change-Id: Ifb606a20f308e7317e9ce519d682a3fdb8bfe9bf

envsetup.sh

index 6bb5587..4e30133 100644 (file)
@@ -1765,13 +1765,13 @@ function godir () {
 
 function cmremote()
 {
-    git remote rm cmremote 2> /dev/null
-    GERRIT_REMOTE=$(git config --get remote.github.projectname)
-    if [ -z "$GERRIT_REMOTE" ]
+    if ! git rev-parse --git-dir &> /dev/null
     then
-        echo Unable to set up the git remote, are you under a git repo?
-        return 0
+        echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+        return 1
     fi
+    git remote rm cmremote 2> /dev/null
+    GERRIT_REMOTE=$(git config --get remote.github.projectname)
     CMUSER=$(git config --get review.review.cyanogenmod.org.username)
     if [ -z "$CMUSER" ]
     then
@@ -1779,17 +1779,18 @@ function cmremote()
     else
         git remote add cmremote ssh://$CMUSER@review.cyanogenmod.org:29418/$GERRIT_REMOTE
     fi
-    echo You can now push to "cmremote".
+    echo "Remote 'cmremote' created"
 }
 
 function aospremote()
 {
-    git remote rm aosp 2> /dev/null
-    if [ ! -d .git ]
+    if ! git rev-parse --git-dir &> /dev/null
     then
-        echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
+        echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+        return 1
     fi
-    PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g`
+    git remote rm aosp 2> /dev/null
+    PROJECT=${$(pwd -P)#$ANDROID_BUILD_TOP/}
     if (echo $PROJECT | grep -qv "^device")
     then
         PFX="platform/"
@@ -1800,12 +1801,13 @@ function aospremote()
 
 function cafremote()
 {
-    git remote rm caf 2> /dev/null
-    if [ ! -d .git ]
+    if ! git rev-parse --git-dir &> /dev/null
     then
-        echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
+        echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+        return 1
     fi
-    PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g`
+    git remote rm caf 2> /dev/null
+    PROJECT=${$(pwd -P)#$ANDROID_BUILD_TOP/}
     if (echo $PROJECT | grep -qv "^device")
     then
         PFX="platform/"