Commit 81d02638 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Update build-sdk.sh

parent 599e4057
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
CURRENT_DIR=`pwd` CURRENT_DIR=`pwd`
# The SDK dir should be 2 directories up in the tree, so we use dirname 2 times # The SDK dir should be 2 directories up in the tree, so we use dirname 2 times
# to get the common parent dir of the SDK and the app # to get the common parent dir of the SDK and the app
GIT=`which git`
tmp=`dirname $CURRENT_DIR` tmp=`dirname $CURRENT_DIR`
tmp=`dirname $tmp` tmp=`dirname $tmp`
SDK_DIR="$tmp/Rocket.Chat.Kotlin.SDK" SDK_DIR="$tmp/Rocket.Chat.Kotlin.SDK"
...@@ -13,23 +14,28 @@ echo "SDK DIR: $SDK_DIR" ...@@ -13,23 +14,28 @@ echo "SDK DIR: $SDK_DIR"
# check if there are changes not commited # check if there are changes not commited
function git_stat { function git_stat {
local __resultvar=$1 local __resultvar=$1
cd $SDK_DIR && git diff --shortstat --exit-code cd $SDK_DIR && $GIT diff --shortstat --exit-code
eval $__resultvar="'$?'" eval $__resultvar="'$?'"
} }
# check for changes already on the index not commited # check for changes already on the index not commited
function git_stat_cached { function git_stat_cached {
local __resultvar=$1 local __resultvar=$1
cd $SDK_DIR && git diff --cached --shortstat --exit-code cd $SDK_DIR && $GIT diff --cached --shortstat --exit-code
eval $__resultvar="'$?'" eval $__resultvar="'$?'"
} }
# get the SHA of the lastest commit # get the SHA of the lastest commit
function git_sha { function git_sha {
temp_sha=`cd $SDK_DIR && git rev-parse --short HEAD` temp_sha=`cd $SDK_DIR && $GIT rev-parse --short HEAD`
echo "$temp_sha" echo "$temp_sha"
} }
function git_app_branch {
temp_branch=`cd $CURRENT_DIR && $GIT rev-parse --abbrev-ref HEAD`
echo "$temp_branch"
}
# check if the tree is dirty (has modifications not commited yet) # check if the tree is dirty (has modifications not commited yet)
function check_git_dirty { function check_git_dirty {
git_stat stat git_stat stat
...@@ -62,7 +68,17 @@ function check_last_commit { ...@@ -62,7 +68,17 @@ function check_last_commit {
return 0 return 0
} }
function checkout_matching_branch {
app_branch=$(git_app_branch)
cd $SDK_DIR && $GIT checkout $app_branch 1>/dev/null 2>/dev/null
}
checkout_matching_branch
SHA=$(git_sha) SHA=$(git_sha)
if [ "X$SHA" == "X" ]; then
SHA="0.1-SNAPSHOT"
fi
echo "CURRENT SHA: $SHA" echo "CURRENT SHA: $SHA"
# if the tree is not dirty, there is no new commit and the .jars are still there, just skip the build # if the tree is not dirty, there is no new commit and the .jars are still there, just skip the build
...@@ -82,4 +98,4 @@ cp -v $SDK_DIR/core/build/libs/core-0.1-SNAPSHOT.jar $CURRENT_DIR/libs/core-$SHA ...@@ -82,4 +98,4 @@ cp -v $SDK_DIR/core/build/libs/core-0.1-SNAPSHOT.jar $CURRENT_DIR/libs/core-$SHA
echo "$SHA" > $SDK_DIR/.last_commit_hash echo "$SHA" > $SDK_DIR/.last_commit_hash
exit 0 exit 0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment