OSDN Git Service

Improve cmremote
authorChirayu Desai <chirayudesai1@gmail.com>
Tue, 16 Dec 2014 12:52:55 +0000 (18:22 +0530)
committerSteve Kondik <steve@cyngn.com>
Sun, 4 Sep 2016 04:47:36 +0000 (21:47 -0700)
Change-Id: I7e1f87ed92cddcf8df3ea4fd701f56a9ef806add

envsetup.sh

index 1d12bd9..f0ee13b 100644 (file)
@@ -1647,21 +1647,13 @@ function godir () {
 function cmremote()
 {
     git remote rm cmremote 2> /dev/null
-    if [ ! -d .git ]
-    then
-        echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
-    fi
-    GERRIT_REMOTE=$(cat .git/config  | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g)
+    GERRIT_REMOTE=$(git config --get remote.github.projectname)
     if [ -z "$GERRIT_REMOTE" ]
     then
-        GERRIT_REMOTE=$(cat .git/config  | grep http://github.com | awk '{ print $NF }' | sed s#http://github.com/##g)
-        if [ -z "$GERRIT_REMOTE" ]
-        then
-          echo Unable to set up the git remote, are you in the root of the repo?
-          return 0
-        fi
+        echo Unable to set up the git remote, are you under a git repo?
+        return 0
     fi
-    CMUSER=`git config --get review.review.cyanogenmod.org.username`
+    CMUSER=$(git config --get review.review.cyanogenmod.org.username)
     if [ -z "$CMUSER" ]
     then
         git remote add cmremote ssh://review.cyanogenmod.org:29418/$GERRIT_REMOTE