omni: Add merge --squash into merge script

Change-Id: I42718264f644a3071b45ae1467168929ebc2c9c4
diff --git a/utils/aosp-merge.sh b/utils/aosp-merge.sh
index 69da619..d3c4587 100755
--- a/utils/aosp-merge.sh
+++ b/utils/aosp-merge.sh
@@ -17,6 +17,15 @@
 echo -e "Enter the AOSP ref to merge";
 read ref;
 
+echo -e "Do you want to merge it like squash ? type "yes" or "no" "
+read squash
+
+OPERATION="${squash}"
+
+branch_name=${ref}"-merge"
+
+branch_current="android-12.1"
+
 cd ../../../
 
 while read path;
@@ -38,6 +47,16 @@
     ret=$(repo sync -d -f --force-sync ${path} 2>&1);
     cd $path;
 
+    if [[ "${OPERATION}" == "yes" ]]; then
+        if git branch | grep ${branch_name} > /dev/null; then
+            git branch -D ${branch_name} > /dev/null
+        fi
+
+        echo " -> creating branch ${branch_name}";
+        ret=$(git checkout -b ${branch_name} 2>&1);
+        ret=$(repo start ${branch_name});
+    fi
+
     # make sure that environment is clean
     ret=$(git merge --abort 2>&1);
 
@@ -46,7 +65,15 @@
 
     if echo $ret | grep "CONFLICT (content)" > /dev/null ; then
         echo -e " -> \e[33mWARNING!: \e[31mMERGE CONFLICT\e[0m";
+        echo -e " -> please fix the merge conflict before push it.";
     else
+        if [[ "${OPERATION}" == "yes" ]]; then
+            echo " -> merging squashed commits into ${branch_current} branch";
+            ret=$(git checkout ${branch_current} 2>&1);
+            ret=$(git merge --squash ${branch_name} 2>&1);
+            ret=$(git add . 2>&1);
+            ret=$(git commit --no-edit 2>&1);
+        fi
         echo -e " -> \e[32mDONE!\e[0m";
     fi
 
diff --git a/utils/caf-merge.sh b/utils/caf-merge.sh
index b995ab7..34c0336 100755
--- a/utils/caf-merge.sh
+++ b/utils/caf-merge.sh
@@ -17,6 +17,15 @@
 echo -e "Enter the CAF ref to merge";
 read ref;
 
+echo -e "Do you want to merge it like squash ? type "yes" or "no" "
+read squash
+
+OPERATION="${squash}"
+
+branch_name=${ref}"-merge"
+
+branch_current="android-12.1"
+
 cd ../../../
 
 while read path;
@@ -38,6 +47,16 @@
     ret=$(repo sync -d -f --force-sync ${path} 2>&1);
     cd $path;
 
+    if [[ "${OPERATION}" == "yes" ]]; then
+        if git branch | grep ${branch_name} > /dev/null; then
+            git branch -D ${branch_name} > /dev/null
+        fi
+
+        echo " -> creating branch ${branch_name}";
+        ret=$(git checkout -b ${branch_name} 2>&1);
+        ret=$(repo start ${branch_name});
+    fi
+
     # make sure that environment is clean
     ret=$(git merge --abort 2>&1);
 
@@ -46,7 +65,15 @@
 
     if echo $ret | grep "CONFLICT (content)" > /dev/null ; then
         echo -e " -> \e[33mWARNING!: \e[31mMERGE CONFLICT\e[0m";
+        echo -e " -> please fix the merge conflict before push it.";
     else
+        if [[ "${OPERATION}" == "yes" ]]; then
+            echo " -> merging squashed commits into ${branch_current} branch";
+            ret=$(git checkout ${branch_current} 2>&1);
+            ret=$(git merge --squash ${branch_name} 2>&1);
+            ret=$(git add . 2>&1);
+            ret=$(git commit --no-edit 2>&1);
+        fi
         echo -e " -> \e[32mDONE!\e[0m";
     fi