mirror of
https://github.com/DictXiong/dotfiles.git
synced 2025-04-25 05:46:55 +08:00
* use update.sh to update safely * add unknown command "version". available: update, force-update, reset, cd and replace tabs with spaces * bug fix * bug fix * uninstall will rm update.sh * new force-update * bug fix * remove thefuck just use `pls` * init post-log.py * update uuid filepath * update.sh will post log * dfs log * bug fix * bug fix * use logging * logging format * bug fix * standarlize the config path * bug fix * add ssh key: ltp2
30 lines
1.0 KiB
Bash
30 lines
1.0 KiB
Bash
#!/bin/bash
|
|
|
|
export DOTFILES=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd )
|
|
# get the specified commit id
|
|
dfs_commit=$(curl -fsSL https://api.beardic.cn/get-var/dfs-commit-id)
|
|
if [[ ${#dfs_commit} != 40 ]]; then
|
|
echo "Error: invalid commit id."
|
|
python3 "${DOTFILES}/tools/post-log.py" "[ERROR] update.sh: invalid commit id: ${dfs_commit}"
|
|
exit
|
|
fi
|
|
# fetch origin
|
|
cd $DOTFILES
|
|
git fetch
|
|
if [[ -n "$(git status -s)" ]]; then
|
|
echo "Error: directory not clean."
|
|
python3 "${DOTFILES}/tools/post-log.py" "[ERROR] update.sh: directory not clean"
|
|
exit
|
|
fi
|
|
# update
|
|
if [[ "$(git rev-parse HEAD)" == "$dfs_commit" ]]; then
|
|
echo "Nothing to do."
|
|
python3 "${DOTFILES}/tools/post-log.py" "[INFO] update.sh: Nothing to do"
|
|
else
|
|
echo "Checking out to commit $dfs_commit ..."
|
|
git -c advice.detachedHead=false checkout $dfs_commit
|
|
cp ./.update.sh ./update.sh
|
|
chmod +x ./update.sh
|
|
python3 "${DOTFILES}/tools/post-log.py" "[INFO] update.sh: Checked out to commit $dfs_commit"
|
|
fi
|