summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur She <arthur.she@linaro.org>2014-09-18 22:57:29 -0700
committerArthur She <arthur.she@linaro.org>2014-09-18 22:57:29 -0700
commit22a1eced0f6179849cee777ae50e7a33144e7137 (patch)
tree94f3692eab041062497bdd580ac1721a8b95e27a
parentbb03e2444a545235d3e98255724258bed28e53d9 (diff)
modified: kselftest-repo-update.sh
-rwxr-xr-xkselftest-repo-update.sh32
1 files changed, 17 insertions, 15 deletions
diff --git a/kselftest-repo-update.sh b/kselftest-repo-update.sh
index 7b6df2a..b3e7d08 100755
--- a/kselftest-repo-update.sh
+++ b/kselftest-repo-update.sh
@@ -2,14 +2,14 @@
#
# This script is used to update in-kernel-tests (kernel_src/tools/testing/selftest)
CONFIG_FILE="./kselftest-repo.conf"
-#CONFIG_FILE="./kselftest-repo-arthur.conf"
. ${CONFIG_FILE}
TCODE_REPO="ssh://git@git.linaro.org/people/arthur.she/in-kernel-tests.git"
-#TCODE_REPO="file:///media/arthur/arthur-usb3/linaro/qa/git/kselftest.git"
WORKING_DIR="/tmp/qa-kselftest"
KSRC_DIR="${WORKING_DIR}/kernel_src"
TCODE_DIR="${WORKING_DIR}/kselftest"
+CREATE_NEW_BRANCH=false
+
checkout_branch () {
# $1: branch name
# $2: Create a new branch if it doesn't exist
@@ -21,14 +21,13 @@ checkout_branch () {
git pull
else
# This branch is not what we want, check out the target branch
-# [ -z "`git branch|grep \"$1$\"`" ] && git checkout -b $1 origin/$1 || git checkout $1
if [ -n "`git branch|grep \"$1$\"`" ]; then
git checkout $1
else
if [ -n "`git branch -a|grep \"origin/$1$\"`" ]; then
git checkout -b $1 origin/$1
else
- [ "${2}" = "true" ] && git checkout -b $1 && return 0 || ret=1
+ [ "${2}" = "true" ] && git checkout -b $1 && CREATE_NEW_BRANCH=true && return 0 || ret=1
fi
fi
[ $? -ne 0 -o $ret -eq 1 ] && echo "Error: Can not checkout branch \"$1\"" && return 1
@@ -39,19 +38,19 @@ checkout_branch () {
clone_repo () {
# $1: git repository
- # $2: the branch we want
- # $3: target directory
+ # $2: target directory
+ # $3: the branch we want
- if [ -d "$3" ]; then
+ if [ -d "$2" ]; then
# The source is exist, update it
- pushd $3 > /dev/null
- checkout_branch $2 false
+ pushd $2 > /dev/null
+ checkout_branch $3 false
[ $? -eq 0 ] && popd > /dev/null || return 1
else
# We have to clone the kernel source
- git clone -b $2 $1 $3
+ [ -n "$3" ] && git clone -b $3 $1 $2 || git clone $1 $2
fi
- [ $? -ne 0 ] && echo "Error: Can not clone branch \"$2\" from repo: $1" && return 1
+ [ $? -ne 0 ] && echo "Error: Can not clone branch \"$3\" from repo: $1" && return 1
return 0
}
@@ -59,7 +58,8 @@ clone_repo () {
# Clone our test code
echo "Cloning test code"
-clone_repo ${TCODE_REPO} master ${TCODE_DIR}
+[ -d ${TCODE_DIR} ] && rm -rf ${TCODE_DIR}
+clone_repo ${TCODE_REPO} ${TCODE_DIR}
[ $? -ne 0 ] && exit 1
pushd ${TCODE_DIR} > /dev/null
for i in `seq 0 $((${#REMOTE_REPO[@]}-1))`;
@@ -69,7 +69,7 @@ do
dir_name=`echo ${KSELFTEST_BRANCH[$i]}|awk '{print $NF}'`
kworking_dir="${KSRC_DIR}/${dir_name}"
echo -e "\nSync with repo: \"${remote_repo}\" branch: \"${remote_branch}\" \n"
- clone_repo ${remote_repo} ${remote_branch} ${kworking_dir}
+ clone_repo ${remote_repo} ${kworking_dir} ${remote_branch}
[ $? -ne 0 ] && continue
pushd ${kworking_dir} > /dev/null
cm=`git log -n1|head -n1|awk '{print $NF}'`
@@ -82,7 +82,7 @@ do
checkout_branch ${b} true
rm -rf *
cp -ra ${kworking_dir}/tools/testing/selftests/* .
- if [ -z "`git status|grep 'nothing to commit'`" ]; then
+ if [ -z "`git status|grep 'nothing to commit'`" -o "${CREATE_NEW_BRANCH}" == "true" ]; then
# There're something changed
echo "We got something changed, update it.."
# Remove files which have been deleted
@@ -93,9 +93,11 @@ do
git commit -m "${commit_comment}"
git tag ${cm}
git push --tag -u origin ${b}
+ CREATE_NEW_BRANCH=false
else
- echo "Already up-to-date."
+ echo "Branch \"${b}\" is already up-to-date."
fi
+ checkout_branch master false
done
done
popd > /dev/null