Skip to content

Commit

Permalink
enhance: some enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
aronchanisme committed May 1, 2024
1 parent bbae18b commit a76c628
Show file tree
Hide file tree
Showing 7 changed files with 564 additions and 238 deletions.
12 changes: 8 additions & 4 deletions bin/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ function build_image()
#fi

image_name="matrixone"
commitid_full=`get_cid less | head -n 2 | tail -n 1`
commitid_less=`echo "${commitid_full:0:8}"`
#commitid_full=`get_cid less | head -n 2 | tail -n 1`
#commitid_less=`echo "${commitid_full:0:8}"`
commitid_less=`get_cid less`

branch=`get_branch | grep "current branch" | awk -F "current branch: " '{print $2}'`

add_log "D" "Commit id full: ${commitid_full}, commit id less: ${commitid_less}, branch: ${branch}"
#branch=`get_branch | grep "current branch" | awk -F "current branch: " '{print $2}'`
branch=`get_branch less`


add_log "D" "Commit id: ${commitid_less}, branch: ${branch}"

if [[ "${commitid_less}" == "" ]] || [[ "${branch}" == "" ]]; then
add_log "E" "Commit id or branch is empty, exiting"
Expand Down
7 changes: 3 additions & 4 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ function git_clone()
rc=1
break;
fi

# git clone and checkout all ok, breaking the loop
rc=0
break;
fi
# git clone and checkout all ok, breaking the loop
rc=0
break;
fi

done
Expand Down
28 changes: 23 additions & 5 deletions bin/get_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function get_branch()
return 1
fi

add_log "I" "Try get mo branch"
if [[ "${option}" != "less" ]]; then
add_log "I" "Try get mo branch"
fi

if [[ ! -d ${MO_PATH}/matrixone ]]; then
add_log "E" "Path ${MO_PATH}/matrixone does not exist, please make sure mo is deployed properly"
add_log "E" "Get branch failed, exiting"
Expand All @@ -25,20 +28,35 @@ function get_branch()

cd ${MO_PATH}/matrixone
if echo "${current_branch}" | grep "HEAD" >/dev/null 2>&1; then
add_log "I" "current_branch is ${current_branch}, contains \"HEAD\" info, thus it's a commit id, trying to find it's real branch"
if [[ "${option}" != "less" ]]; then
add_log "I" "current_branch is ${current_branch}, contains \"HEAD\" info, thus it's a commit id, trying to find it's real branch"
fi
commitid_full=`git log | head -n 1 | awk {'print $2'}`
commitid_less=`echo "${commitid_full:0:8}"`
current_branch=`git branch --contains ${cid_less} | grep -v HEAD | sed 's/ //g'`
fi

if [[ "${current_branch}" != "" ]]; then
add_log "I" "Get branch succeeded, current branch: ${current_branch}"
MO_V_TYPE="branch"
if [[ "${option}" != "less" ]]; then
add_log "I" "Get branch succeeded, current branch: ${current_branch}"
else
echo "${current_branch}"
fi
else
add_log "I" "No branch contains this commit, try to match a tag"
if [[ "${option}" != "less" ]]; then
add_log "I" "No branch contains this commit, try to match a tag"
fi
current_tag=`git tag --contains ${cid_less} | grep -v HEAD | sed 's/ //g' | sort | head -1`
if [[ "${current_tag}" != "" ]]; then
add_log "I" "Get tag succeeded, current tag: ${current_tag}"
MO_V_TYPE="tag"
if [[ "${option}" != "less" ]]; then
add_log "I" "Get tag succeeded, current tag: ${current_tag}"
else
echo "${current_tag}"
fi
else
MO_V_TYPE="unkown"
add_log "E" "Get tag failed"
fi
return 1
Expand Down
11 changes: 9 additions & 2 deletions bin/get_cid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ function get_cid()
return 1
fi

add_log "I" "Try get mo commit id"
if [[ "${option}" != "less" ]]; then
add_log "I" "Try get mo commit id"
fi

if [[ ! -d ${MO_PATH}/matrixone ]]; then
add_log "E" "Path ${MO_PATH}/matrixone does not exist, please make sure mo is deployed properly"
add_log "E" "Get commit id failed, exiting"
Expand All @@ -24,6 +27,7 @@ function get_cid()
# better way to get commit id
cid_full=`cd ${MO_PATH}/matrixone && git log -n 1`
cid_less=`cd ${MO_PATH}/matrixone && git log -n 1 --format='%H'`
cid_less=`echo "${cid_less:0:8}"`

#deprecated:
#cid_full="$(cd ${MO_PATH}/matrixone && git log | head -n 6)"
Expand All @@ -34,7 +38,10 @@ function get_cid()
else
echo "${cid_full}"
fi
add_log "I" "Get commit id succeeded"

if [[ "${option}" != "less" ]]; then
add_log "I" "Get commit id succeeded"
fi
else
add_log "E" "Get commit id failed"
return 1
Expand Down
Loading

0 comments on commit a76c628

Please sign in to comment.