fix: restore git-diff mode to fix v1.0.1 Vela regression#7
Merged
Conversation
PR #5 removed scripts/start.sh which used to run `git fetch` + `git diff` and pipe the result into the plugin. Callers that relied on that behaviour (e.g. Vela pipelines that never set PARAMETER_DIFF_SOURCE) now get empty stdin and see "0 of 0 changed instructions covered". Add PARAMETER_DIFF_SOURCE=git that runs the same git commands internally, using PARAMETER_BASE_BRANCH (or VELA_PULL_REQUEST_TARGET for backward compatibility) as the base ref. Auto-detect: when PARAMETER_DIFF_SOURCE is absent but VELA_PULL_REQUEST_TARGET is set the runner silently defaults to "git", so existing Vela pipelines recover without any configuration change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two bugs in TestDefaultRunner_Run_DiffSourceAutodetect_VelaTarget: - Used assert.Error instead of require.Error: when err is nil the next line calls err.Error() and panics with a nil pointer dereference. - Used "main" as the Vela target branch: in CI the repo has origin/main so git fetch succeeds, err stays nil, and the test fails. Fix both: switch to require.Error (stops the test on nil) and use a branch name that cannot exist on any remote so git fetch always fails. Also fix gofmt whitespace in runner.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
golangci-lint flags exec.Command calls with variable args as G204. The args are built from our own logic (not raw user input), so suppress the warning with nolint comments — same pattern used elsewhere in the repo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🛡️ Patch Coverage Report
Diff coverage:
Lines = the source lines you changed. Instructions = the executable units the coverage tool counts inside those lines — one line can hold several (e.g. JaCoCo bytecode), so the two counts differ. Coverage by file
1 changed file(s) with no measurable lines (config, docs, generated, or test-only) omitted. 🔍 Uncovered lines (14)🤖 Generated by pull-request-code-coverage — coverage for changed lines only. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What broke
PR #5 removed
scripts/start.shand changed the Docker entrypoint from/start.shto/plugindirectly. That shell script was responsible for runninggit fetch+git diff --unified=0and piping the result into the plugin. Without it,PARAMETER_DIFF_SOURCEdefaults tostdinwhich is now empty → 0 of 0 changed instructions covered.Fix
internal/plugin/gitdiff/diff.go— runsgit fetch --no-tags origin <base>thengit diff --unified=0 origin/<base>internally, reproducing whatstart.shused to do.PARAMETER_DIFF_SOURCE=git— explicit opt-in for any CI.PARAMETER_DIFF_SOURCEis unset butVELA_PULL_REQUEST_TARGETis present, the runner automatically switches togitmode. Existing Vela pipelines recover with zero config changes.PARAMETER_BASE_BRANCH— explicit override for non-Vela CIs usinggitmode.Gap test added
TestDefaultRunner_Run_DiffSourceAutodetect_VelaTargetcovers the exact scenario that slipped through: noPARAMETER_DIFF_SOURCE,VELA_PULL_REQUEST_TARGETset, empty stdin. Without the fix this test would have failed when PR #5 landed, catching the regression before merge.Generated by Claude Code