mirror of
https://github.com/DictXiong/dotfiles.git
synced 2026-11-23 20:38:16 +08:00
WIP: piv fix (#28)
* piv logi fix * dogo: $DFS * snasp; doll: $2 for the name * DFS_UPDATE_CHANNEL? * git-branches * ci: git-branches Co-authored-by: xiongdian.me <xiongdian.me@bytedance.com>
This commit is contained in:
26
.update.sh
26
.update.sh
@@ -3,15 +3,10 @@
|
||||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
||||
THIS_FILE=$(basename "${BASH_SOURCE}")
|
||||
source "$THIS_DIR/tools/common.sh"
|
||||
DFS_ENABLE_RET=${DFS_ENABLE_RET:-0}
|
||||
|
||||
# get the specified commit id
|
||||
DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
||||
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
||||
fmt_error "invalid commit id"
|
||||
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
||||
exit
|
||||
fi
|
||||
DFS_UPDATED_RET=${DFS_UPDATED_RET:-0}
|
||||
DFS_UPDATE_CHANNEL=${DFS_UPDATE_CHANNEL:-"main"}
|
||||
|
||||
# fetch origin
|
||||
cd $DOTFILES
|
||||
git fetch --all
|
||||
@@ -20,6 +15,19 @@ if [[ -n "$(git status -s)" ]]; then
|
||||
post_log "ERROR" "$THIS_FILE" "directory not clean"
|
||||
exit
|
||||
fi
|
||||
|
||||
# get the specified commit id
|
||||
case $DFS_UPDATE_CHANNEL in
|
||||
"main" ) DFS_COMMIT=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id) ;;
|
||||
"latest" ) DFS_COMMIT=$(git for-each-ref --sort=-committerdate refs/heads refs/remotes --format='%(objectname)' | head -n 1) ;;
|
||||
* ) fmt_fatal "invalid update channel: $DFS_UPDATE_CHANNEL" ;;
|
||||
esac
|
||||
if [[ ${#DFS_COMMIT} != 40 ]]; then
|
||||
fmt_error "invalid commit id"
|
||||
post_log "ERROR" "$THIS_FILE" "invalid commit id: ${DFS_COMMIT}"
|
||||
exit
|
||||
fi
|
||||
|
||||
# update
|
||||
if [[ "$(git rev-parse HEAD)" == "$DFS_COMMIT" ]]; then
|
||||
fmt_info "nothing to do"
|
||||
@@ -29,7 +37,7 @@ else
|
||||
if [[ -z "$DFS_DEV" ]]; then
|
||||
post_log "INFO" "$THIS_FILE" "will check out to commit $DFS_COMMIT"
|
||||
git -c advice.detachedHead=false checkout $DFS_COMMIT
|
||||
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit $DFS_ENABLE_RET
|
||||
cp ./.update.sh ./update.sh && chmod +x ./update.sh && exit $DFS_UPDATED_RET
|
||||
else
|
||||
fmt_warning "won't really checkout in dev mode"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user