fix: always clean-clone source dir, drop stale master refspec workaround
The old .git/config in /opt/nixpanel/src had a fetch refspec pointing to refs/heads/master (from before the branch rename). Re-running the installer with that directory present caused 'git fetch' to fail with 'couldn't find remote ref refs/heads/master'. Fix: rm -rf the source dir before cloning whenever the source step hasn't been marked done, so we always get a clean checkout with the correct branch.
This commit is contained in:
+5
-10
@@ -178,16 +178,11 @@ if ! step_done "source"; then
|
||||
[[ -z "$LATEST_TAG" ]] && LATEST_TAG="main"
|
||||
info "Fetching tag: $LATEST_TAG"
|
||||
|
||||
if [[ -d "$SRC_DIR/.git" ]]; then
|
||||
git -C "$SRC_DIR" fetch --tags --quiet
|
||||
git -C "$SRC_DIR" checkout "$LATEST_TAG" --quiet
|
||||
else
|
||||
# Try with explicit branch first, then fallback to explicit 'main' branch
|
||||
git clone --depth 1 --branch "$LATEST_TAG" \
|
||||
"https://github.com/${GITHUB_REPO}.git" "$SRC_DIR" 2>/dev/null \
|
||||
|| git clone --depth 1 --branch main \
|
||||
"https://github.com/${GITHUB_REPO}.git" "$SRC_DIR"
|
||||
fi
|
||||
# Always do a clean clone when re-running this step — avoids stale .git configs
|
||||
# (e.g. old clones that tracked 'master' before the branch was renamed to 'main')
|
||||
rm -rf "$SRC_DIR"
|
||||
git clone --depth 1 --branch "$LATEST_TAG" \
|
||||
"https://github.com/${GITHUB_REPO}.git" "$SRC_DIR"
|
||||
mark_done "source"
|
||||
fi
|
||||
success "Source ready"
|
||||
|
||||
Reference in New Issue
Block a user