Skip to content

fix: restore git-diff mode to fix v1.0.1 Vela regression#7

Merged
CodeYogiCo merged 3 commits into
masterfrom
claude/last-pr-regression-rkrx7t
Jun 24, 2026
Merged

fix: restore git-diff mode to fix v1.0.1 Vela regression#7
CodeYogiCo merged 3 commits into
masterfrom
claude/last-pr-regression-rkrx7t

Conversation

@CodeYogiCo

Copy link
Copy Markdown
Owner

What broke

PR #5 removed scripts/start.sh and changed the Docker entrypoint from /start.sh to /plugin directly. That shell script was responsible for running git fetch + git diff --unified=0 and piping the result into the plugin. Without it, PARAMETER_DIFF_SOURCE defaults to stdin which is now empty → 0 of 0 changed instructions covered.

Fix

  • New internal/plugin/gitdiff/diff.go — runs git fetch --no-tags origin <base> then git diff --unified=0 origin/<base> internally, reproducing what start.sh used to do.
  • PARAMETER_DIFF_SOURCE=git — explicit opt-in for any CI.
  • Auto-detect for Vela — when PARAMETER_DIFF_SOURCE is unset but VELA_PULL_REQUEST_TARGET is present, the runner automatically switches to git mode. Existing Vela pipelines recover with zero config changes.
  • PARAMETER_BASE_BRANCH — explicit override for non-Vela CIs using git mode.

Gap test added

TestDefaultRunner_Run_DiffSourceAutodetect_VelaTarget covers the exact scenario that slipped through: no PARAMETER_DIFF_SOURCE, VELA_PULL_REQUEST_TARGET set, empty stdin. Without the fix this test would have failed when PR #5 landed, catching the regression before merge.


Generated by Claude Code

claude added 3 commits June 24, 2026 16:12
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>
@CodeYogiCo CodeYogiCo merged commit 54ccf6c into master Jun 24, 2026
2 checks passed
@github-actions

Copy link
Copy Markdown

🛡️ Patch Coverage Report

Scope: changed lines only — the code this PR adds or edits, not whole files or the repo. It answers one thing — did your tests run the code you just touched?

Diff coverage: 73% 🟡 — 38 of 52 changed instructions covered

Metric Value
🟢 Covered instructions 38 (73%) changed code your tests executed
🔴 Missed instructions 14 (27%) changed code your tests never ran
📈 Tracked changed lines 52 (40%) lines the coverage tool could measure
⚪ Untracked changed lines 78 (60%) comments, blanks, declarations

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

File Diff coverage Covered / Missed
internal/plugin/gitdiff/diff.go 🟡 50% 13 / 13
internal/plugin/runner.go 🟢 96% 25 / 1

1 changed file(s) with no measurable lines (config, docs, generated, or test-only) omitted.

🔍 Uncovered lines (14)
--- internal/plugin/gitdiff/diff.go:42
	diffArgs := []string{"--no-pager", "diff", "--unified=0", "origin/" + l.baseBranch}
--- internal/plugin/gitdiff/diff.go:43
	if l.module != "" {
--- internal/plugin/gitdiff/diff.go:44
		diffArgs = append(diffArgs, l.module)
--- internal/plugin/gitdiff/diff.go:45
	}
--- internal/plugin/gitdiff/diff.go:46
	logrus.Infof("running git %v", diffArgs)
--- internal/plugin/gitdiff/diff.go:47
	diffCmd := exec.Command("git", diffArgs...) //nolint:gosec // args are controlled internally, not user input
--- internal/plugin/gitdiff/diff.go:48
	var stdout, stderr bytes.Buffer
--- internal/plugin/gitdiff/diff.go:49
	diffCmd.Stdout = &stdout
--- internal/plugin/gitdiff/diff.go:50
	diffCmd.Stderr = &stderr
--- internal/plugin/gitdiff/diff.go:51
	if err := diffCmd.Run(); err != nil {
--- internal/plugin/gitdiff/diff.go:52
		return nil, errors.Wrapf(err, "git diff failed: %s", stderr.String())
--- internal/plugin/gitdiff/diff.go:53
	}
--- internal/plugin/gitdiff/diff.go:55
	return &stdout, nil
--- internal/plugin/runner.go:137
		changedSourceLinesSource = diffReader

🤖 Generated by pull-request-code-coverage — coverage for changed lines only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants