Merge "vendor/omni: minor code cleanup" into android-4.4
diff --git a/utils/forkrepo.sh b/utils/fork_aosp.sh
similarity index 63%
rename from utils/forkrepo.sh
rename to utils/fork_aosp.sh
index 2ee652d..3064b42 100755
--- a/utils/forkrepo.sh
+++ b/utils/fork_aosp.sh
@@ -3,21 +3,20 @@
# Licensed under GPLv3
# Configuration
-CONFIG_ROOT=~/gitolite-admin/
-CONFIG_FILE=$CONFIG_ROOT/conf/gitolite.conf
-ANDROID_ROOT=~/android
+ANDROID_ROOT=~/omni
PREFIX=android_
-BRANCH=android-4.3
-SOURCE=android-4.3_r2.2
+BRANCH=android-4.4
+SOURCE=android-4.4.2_r1
MANIFEST=android/default.xml
-XDA_REMOTE=ssh://git@localhost # NO TRAILING SLASH
-GERRIT_REMOTE=ssh://build1.dev.xda-developers.com:29418
-REMOTE_MANIFEST=private
+GITHUB_ORG=omnirom
+USERNAME=xplodwild
+GERRIT_REMOTE=ssh://gerrit.omnirom.org:29418
+REMOTE_MANIFEST=omnirom
# Script
if [ $# -lt 1 ]; then
- echo Usage: ./clone.sh path
- echo Example: ./clone.sh frameworks/base
+ echo Usage: ./fork_aosp.sh path
+ echo Example: ./fork_aosp.sh frameworks/base
exit 1
fi
@@ -32,40 +31,23 @@
fi
popd
-CURRENT_DIR=$(pwd)
-cd $CONFIG_ROOT
-git pull
-cd $CURRENT_DIR
-
-# Create the repo inside gitolite
-echo "Creating $REPO_NAME..."
-
-echo "" >> $CONFIG_FILE
-echo "repo $REPO_NAME" >> $CONFIG_FILE
-echo " RW+ = pulser" >> $CONFIG_FILE
-echo " RW+ = xplodwild" >> $CONFIG_FILE
-echo " R = @all" >> $CONFIG_FILE
-echo "" >> $CONFIG_FILE
-
-echo "Comitting and pushing..."
-CURRENT_DIR=$(pwd)
-cd $CONFIG_ROOT
-git commit conf/gitolite.conf -m "Add $REPO_NAME"
-git push
+# Create the repo at github
+echo "Creating $REPO_NAME on GitHub..."
+curl --user $USERNAME --data "{\"name\":\"$REPO_NAME\"}" https://api.github.com/orgs/$GITHUB_ORG/repos
# Only works if you are a gerrit admin, will create the named project before pushing (gerrit then replicates to git)
-
ssh -p 29418 gerrit.omnirom.org gerrit create-project --name $REPO_NAME
echo "Creating branch $BRANCH..."
-cd $CURRENT_DIR/$1
+pushd $1
+git remote rm gerrit
git remote add gerrit $GERRIT_REMOTE/$REPO_NAME
git checkout $SOURCE
git branch $BRANCH
git push gerrit $BRANCH
echo "Updating manifest..."
-cd $ANDROID_ROOT
+popd
SRC_LINE=$(cat $MANIFEST | grep ${1%/} | head -n1)
if [[ "$SRC_LINE" == *group="pdk"* ]]; then
NEW_LINE=" <project path=\"${1%/}\" name=\"$REPO_NAME\" remote=\"$REMOTE_MANIFEST\" revision=\"$BRANCH\" group=\"pdk\" />"
@@ -78,10 +60,11 @@
sed -i "s%$SRC_LINE%$NEW_LINE%g" $MANIFEST
echo "Pushing manifest"
-cd $ANDROID_ROOT/android
+pushd android
git checkout $BRANCH
git commit -a -m "Replace $1 path to new repository $REPO_NAME"
git push $GERRIT_REMOTE/android HEAD:refs/for/$BRANCH
+popd
echo "Now remember to approve the change on gerrit before going further!"
read -p "Press [Enter] key once you've approved the change on gerrit"
diff --git a/utils/fork_github.sh b/utils/fork_github.sh
new file mode 100755
index 0000000..4e60ec0
--- /dev/null
+++ b/utils/fork_github.sh
@@ -0,0 +1,78 @@
+#!/bin/bash
+
+# Tool for forking a GitHub repository to another GitHub org,
+# by creating the repo on GitHub and Gerrit, and pushing
+# the source repo to Gerrit.
+# The name of the repository can be changed before forking,
+# and if the regular branch isn't found, you can choose
+# in the list of available branches.
+# Usage: ./fork.sh
+
+##
+# Configuration
+##
+USERNAME=xplodwild
+BRANCH=android-4.4
+GERRIT=gerrit.omnirom.org
+GITHUB_ORG=omnirom
+
+##
+# Script
+##
+
+# Read the source GitHub URL
+read -p "GitHub URL (no trailing slash): " github_url
+
+# Extract the repo name and prompt for changes
+repo_name=${github_url##*/}
+original_repo_name=$repo_name
+
+read -e -i "$repo_name" -p "Final repo name: " repo_name
+
+# Clone the repo locally
+git clone $github_url
+
+# Create the new repository on the organization
+echo Creating $repo_name on GitHub
+
+curl --user $USERNAME --data "{\"name\":\"$repo_name\"}" https://api.github.com/orgs/$GITHUB_ORG/repos
+
+# Create the repository on Gerrit
+echo Creating $repo_name on Gerrit
+
+ssh -p 29418 $GERRIT gerrit create-project --name $repo_name
+
+# Push the repository
+cd $original_repo_name
+
+git checkout $BRANCH
+git show-ref --verify --quiet refs/heads/$BRANCH
+
+if [ $? != 0 ]; then
+ echo "Branch $BRANCH doesn't exist in the original repository"
+ echo "Here are the branches:"
+ git branch -a
+ echo "--------------------------------------"
+ read -p "Branch to clone from: " origin_branch
+ git checkout $origin_branch
+ git branch $BRANCH
+fi
+
+git push ssh://gerrit.omnirom.org:29418/$repo_name $BRANCH
+
+# If pushing failed, we might want to forcepush the repository
+# to overwite what was previously there.
+if [ $? != 0 ]; then
+ echo "Unable to push!"
+ read -p "Try with -f? [y/n]: " forcepush
+ if [ "$forcepush" = "y" ]; then
+ git psuh -f ssh://gerrit.omnirom.org:29418/$repo_name $BRANCH
+ fi
+fi
+
+# Cleanup our local copy
+cd ..
+rm -rf $original_repo_name
+
+# Done!
+echo "Fork done!"