Detect if git repo is shallow, and unshallow it

This commit is contained in:
LukeZGD 2024-02-17 16:49:15 +08:00
parent 853a698d83
commit 22eb99b358

View File

@ -393,6 +393,8 @@ version_update() {
fi fi
if [[ -d .git ]]; then if [[ -d .git ]]; then
log "Running git pull..." log "Running git pull..."
print "* If this fails for some reason, run: git reset --hard"
print "* To clean more files if needed, run: git clean -df"
git pull git pull
log "Done! Please run the script again" log "Done! Please run the script again"
exit exit
@ -427,6 +429,10 @@ version_update() {
version_get() { version_get() {
pushd .. >/dev/null pushd .. >/dev/null
if [[ -d .git ]]; then if [[ -d .git ]]; then
if [[ -e .git/shallow ]]; then
log "Shallow git repository detected. Unshallowing..."
git fetch --unshallow
fi
git_hash=$(git rev-parse HEAD | cut -c -7) git_hash=$(git rev-parse HEAD | cut -c -7)
local dm=$(git log -1 --format=%ci | cut -c 3- | cut -c -5) local dm=$(git log -1 --format=%ci | cut -c 3- | cut -c -5)
version_current=v${dm//-/.}. version_current=v${dm//-/.}.