File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121SKIP_SSH_KEYSCAN_OPTION=" $( plugin_read_config SKIP_SSH_KEYSCAN " false" ) "
2222CLEAN_CHECKOUT_OPTION=" $( plugin_read_config CLEAN_CHECKOUT " false" ) "
2323
24+ if [[ " ${CLEAN_CHECKOUT_OPTION} " = " true" ]]; then
25+ echo " ⚠️ WARNING: clean_checkout is enabled - this will destroy any local changes and reset the repository state"
26+ fi
27+
2428if [[ -n " ${BUILDKITE_REPO_SSH_HOST:- } " ]] && [[ " ${SKIP_SSH_KEYSCAN_OPTION} " = " false" ]] ; then
2529 echo " Scanning SSH keys for remote git repository"
2630 [[ -d ~ /.ssh ]] || mkdir -p ~ /.ssh
4549# Enable clean checkout option to deal with corrupted repository states
4650if [[ " ${CLEAN_CHECKOUT_OPTION} " = " true" ]]; then
4751 echo " Clean checkout enabled - resetting repository state"
48- # Reset any changes that might prevent checkout
49- git reset --hard HEAD 2> /dev/null || true
50- # Clean all untracked files and directories
51- git clean -ffxdq
52- # Reset sparse-checkout configuration
53- git sparse-checkout disable 2> /dev/null || true
54- else
55- git clean -ffxdq
56- fi
52+ # Remove index lock files
53+ find .git -name " *.lock" -delete 2> /dev/null || true
54+ # Reset index if corrupted
55+ if ! git status > /dev/null 2>&1 ; then
56+ rm -f .git/index 2> /dev/null || true
57+ fi
58+ # Disable sparse-checkout
59+ git sparse-checkout disable 2> /dev/null || true
60+ # Clean and reset
61+ git clean -ffxdq
62+
63+ if git rev-parse --verify HEAD > /dev/null 2>&1 ; then
64+ git reset --hard HEAD
65+ fi
66+ else
67+ git clean -ffxdq
68+ fi
5769
5870FETCH_FLAGS=()
5971if [[ -n " ${BUILDKITE_GIT_FETCH_FLAGS:- } " ]]; then
You can’t perform that action at this time.
0 commit comments