makerecipe: WIP to generate manifest branches for releases

Change-Id: I1804c180844043692f788275c8998307e348001b
diff --git a/envsetup.sh b/envsetup.sh
index d20d874..23d4bcf 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1533,8 +1533,12 @@
     GERRIT_REMOTE=$(cat .git/config  | grep git://github.com | awk '{ print $NF }' | sed s#git://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
+        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
     fi
     CMUSER=`git config --get review.review.cyanogenmod.com.username`
     if [ -z "$CMUSER" ]
@@ -1545,6 +1549,29 @@
     fi
     echo You can now push to "cmremote".
 }
+export -f cmremote
+
+function makerecipe() {
+  if [ -z "$1" ]
+  then
+    echo "No branch name provided."
+    return 1
+  fi
+  cd android
+  sed -i s/'default revision=.*'/'default revision="refs\/heads\/'$1'"'/ default.xml
+  git commit -a -m "$1"
+  cd ..
+
+  repo forall -c '
+
+  if [ "$REPO_REMOTE" == "github" ]
+  then
+    pwd
+    cmremote
+    git push cmremote HEAD:refs/heads/'$1'
+  fi
+  '
+}
 
 function cmgerrit() {
     if [ $# -eq 0 ]; then