upload tizen1.0 source
[framework/web/web-ui-fw.git] / libs / patch / prepare-patch.sh
1 #!/bin/bash
2
3 cd `dirname $0`/../../
4 CWD=`pwd`
5 LIB_DIR=${CWD}/libs
6 PATCH_DIR=$LIB_DIR/patch
7
8 CURRENT_BRANCH="`git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`"
9 PATCH_BRANCH=temp-patch
10 CURRENT_BRANCH_FILE=${CWD}/.current_branch.txt
11
12 function reset_branch
13 {
14         echo "Restore to original git branch."
15         test -f "$CURRENT_BRANCH_FILE" && CURRENT_BRANCH="`cat $CURRENT_BRANCH_FILE`"
16         git checkout ${CURRENT_BRANCH}
17         git branch -D ${PATCH_BRANCH}
18         rm -f $CURRENT_BRANCH_FILE
19         exit 1
20 }
21
22 # If --cancel option is given, just reset git and exit.
23 test "$1" == "--cancel" && reset_branch
24
25 # Remember current branch name to a file
26 echo "${CURRENT_BRANCH}" > $CURRENT_BRANCH_FILE
27
28 # Make sure if current git is clear.
29 #test -n "`git status -s`" && echo "ERROR: Current git is not clean. Type 'git status' and clean your git up first." && exit 1
30
31 # Reset git 
32 #git reset --hard HEAD
33
34 # Create a temporary branch
35 git branch ${PATCH_BRANCH}       || reset_branch
36 git checkout ${PATCH_BRANCH} || reset_branch
37
38 # Apply existing patches into libs/
39 cd ${LIB_DIR}
40 #for patch in `find ${PATCH_DIR} -name '*.patch' -type f`; do
41 #       patch -p0 < ${patch} || reset_branch
42 #done
43 git am $PATCH_DIR/*.patch
44
45 # Make a temporary commit on $PATCH_BRANCH
46 #git add -f -u .        || reset_branch
47 #git commit -m 'Temporary commit applying existing patches'     || reset_branch
48
49
50 # Done. Notice howto
51 echo ""
52 echo "Set up for patch is done. Current temporary git branch name is '${PATCH_BRANCH}', and a temporary commit is created. (This commit and branch will be removed.)"
53 echo "Go change your source, add&commit into git, and run create-patch.sh to make your commit to a patch file in $PATCH_DIR."
54