Skip to content

Fix os.Exit in goroutines, Makefile macOS compat, and JSON round-trip tests#107

Open
briansumma wants to merge 6 commits into
gildas:masterfrom
briansumma:develop-pr
Open

Fix os.Exit in goroutines, Makefile macOS compat, and JSON round-trip tests#107
briansumma wants to merge 6 commits into
gildas:masterfrom
briansumma:develop-pr

Conversation

@briansumma
Copy link
Copy Markdown

@briansumma briansumma commented Jun 1, 2026

Summary

  • Fix os.Exit calls in goroutines and error pathscmd/profile/authorize.go called os.Exit(1) inside a goroutine, preventing cleanup; cmd/pullrequest/create.go used os.Exit(1) instead of returning errors through Cobra. Both now propagate errors properly.

  • Fix Makefile test target for macOS compatibility — The test target used $(COVERAGE_OUT) as a prerequisite, which relied on GNU Make 4 features unavailable in macOS default make. Inlined the test recipe so make test works out of the box. Also migrated tool installation from deprecated go get to go install with @latest.

  • Fix JSON round-trip test failuresMarshalJSON on Commit and User structs emitted zero-value fields (author: {}, date: "0001-01-01...") that were absent in the original API fixtures, causing TestCanUnmarshal assertions to fail. Added omitempty-style nil guards so marshal output matches unmarshal input.

Test plan

  • go build ./... passes
  • go vet ./... passes
  • TestPullRequestSuite/TestCanUnmarshal passes
  • TestPullRequestSuite/TestCanUnmarshalWithNilDestinationRepository passes
  • Full test suite (make test on GNU Make 4+)
  • Verify make coverage-report produces XML output

briansumma and others added 6 commits June 1, 2026 17:14
- cmd/profile/authorize.go: Replace os.Exit(1) in goroutine with
  sending error to result channel, allowing proper cleanup
- cmd/pullrequest/create.go: Replace fmt.Fprintf+os.Exit(1) with
  return err for proper error propagation through Cobra
- main.go: Add comment clarifying .env load error is expected

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Makefile:
- Inline test recipe to avoid $(COVERAGE_OUT) prerequisite requiring
  GNU Make 4 features unavailable on macOS default make
- Add coverage-report target and restore GOCOV/GOCOVXML variables
- Add coverage-report to .PHONY declaration
- Use go install with @latest instead of deprecated go get for tools

Tests:
- cmd/commit: Fix MarshalJSON to omit zero-value fields, fixing
  round-trip assertion failures in TestCanUnmarshal
- cmd/user: Fix MarshalJSON to use time pointer for omitempty
- testdata/: Update branch, commit, and pullrequest fixtures to
  match actual Bitbucket API response structure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Bring develop-pr fully in sync with develop (excluding planning files:
CLAUDE.md, .codegraph/, docs/bitbucket-swagger.v3.json).

Changes applied from develop:
- go.mod/go.sum: update go-flags v0.5.0, go-logger v1.9.5, go-git v5.19.1,
  and other upstream dep bumps; add gocov/gocov-xml as direct requires
- tools/tools.go: pin gocov/gocov-xml via build-tag tools file
- cmd/repository/repository.go: add omitempty to HasIssues/HasWiki/IsPrivate
- Makefile: exclude tools/ from GOFILES, fix COVERAGE_OUT path, fix
  coverage-report to use file prereq, add coverage-tools target
- cmd/profile, cmd/pullrequest, cmd/pipeline, cmd/issue, cmd/root, etc.:
  update callers to go-flags v0.5.0 NewEnumFlagWithFunc API (cmd arg added)
- version.go, packaging/: version and packaging metadata from master rebase
- cmd/common/config.go: new file from upstream
- cmd/pullrequest/comment/create_test.go: new test from upstream

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use Author.IsEmpty() instead of an ad-hoc Type/UserID check so authors
with only a Raw field (non-Bitbucket-registered users) are not silently
dropped from commit JSON output.

Add the same [ -x ] existence guard to coverage-report that the test
target already uses, so a failed tool installation fails with a clear
message rather than a cryptic silent error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t feedback

Add TestCanMarshalRawOnlyAuthor to verify that commits from non-Bitbucket-
registered users (Author.Raw set, Type and User empty) include the author
in marshaled JSON output — the exact regression fixed in the prior commit.

Add an else branch to the coverage-report Makefile target so missing
coverage tools produce a clear message instead of a silent no-op exit.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant