@@ -196,7 +196,36 @@ check_linter_support() {
196196
197197# Find golangci-lint binary
198198find_golangci_lint () {
199- # Check for custom build first
199+ # Check if Variables.mk exists and extract golangci-lint path
200+ if [[ -f " .bingo/Variables.mk" ]]; then
201+ # Extract version from GOLANGCI_LINT variable
202+ # Format: GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.7.2
203+ local version
204+ version=$( grep ' ^GOLANGCI_LINT' .bingo/Variables.mk | sed -E ' s/.*golangci-lint-(v[0-9]+\.[0-9]+\.[0-9]+).*/\1/' )
205+
206+ if [[ -n " ${version} " ]]; then
207+ # Use go env to get the actual GOBIN/GOPATH
208+ local gobin
209+ gobin=$( go env GOBIN)
210+
211+ # If GOBIN is empty, use GOPATH/bin
212+ if [[ -z " ${gobin} " ]]; then
213+ local gopath
214+ gopath=$( go env GOPATH)
215+ # Take first entry if GOPATH has multiple paths (colon-separated)
216+ gobin=" ${gopath%%:* } /bin"
217+ fi
218+
219+ # Check if the versioned binary exists
220+ local bingo_path=" ${gobin} /golangci-lint-${version} "
221+ if [[ -f " ${bingo_path} " ]]; then
222+ echo " ${bingo_path} "
223+ return 0
224+ fi
225+ fi
226+ fi
227+
228+ # Check for custom build
200229 if [[ -f " .bingo/golangci-lint" ]]; then
201230 echo " .bingo/golangci-lint"
202231 return 0
@@ -216,6 +245,7 @@ find_golangci_lint() {
216245
217246 echo -e " ${RED} Error: golangci-lint not found.${NC} " >&2
218247 echo -e " ${RED} Searched for:${NC} " >&2
248+ echo -e " - .bingo/Variables.mk (bingo-managed versioned binary)" >&2
219249 echo -e " - .bingo/golangci-lint" >&2
220250 echo -e " - bin/golangci-lint" >&2
221251 echo -e " - golangci-lint on your \$ PATH" >&2
@@ -482,6 +512,23 @@ main() {
482512 # Create temporary config
483513 create_temp_config
484514
515+ # Ensure baseline branch is available (important for CI environments like GitHub Actions)
516+ if ! git rev-parse --verify " ${BASELINE_BRANCH} " & > /dev/null; then
517+ echo -e " ${YELLOW} Baseline branch '${BASELINE_BRANCH} ' not found locally. Fetching from origin...${NC} " >&2
518+
519+ # Fetch the baseline branch from origin
520+ if ! git fetch origin " ${BASELINE_BRANCH} :${BASELINE_BRANCH} " 2>&1 ; then
521+ # If direct fetch fails, try fetching with remote tracking
522+ if ! git fetch origin " ${BASELINE_BRANCH} " 2>&1 ; then
523+ echo -e " ${RED} Error: Failed to fetch baseline branch '${BASELINE_BRANCH} ' from origin${NC} " >&2
524+ echo -e " ${RED} Please ensure the branch exists in the remote repository.${NC} " >&2
525+ exit 1
526+ fi
527+ # Use the remote tracking branch
528+ BASELINE_BRANCH=" origin/${BASELINE_BRANCH} "
529+ fi
530+ fi
531+
485532 # Get changed files
486533 get_changed_files > " ${TEMP_DIR} /changed_files.txt"
487534
0 commit comments