Skip to content

Update to go-github v87#92

Open
SamMorrowDrums wants to merge 3 commits into
migueleliasweb:masterfrom
SamMorrowDrums:sammorrowdrums/upgrade-go-github-v87
Open

Update to go-github v87#92
SamMorrowDrums wants to merge 3 commits into
migueleliasweb:masterfrom
SamMorrowDrums:sammorrowdrums/upgrade-go-github-v87

Conversation

@SamMorrowDrums
Copy link
Copy Markdown

Bumps github.com/google/go-github from v73 → v87 (latest) and regenerates the endpoint patterns from the current GitHub OpenAPI description.

go-github v87 breaking changes that affect this repo

  • github.NewClient now uses a functional-options pattern and returns (*Client, error). All github.NewClient(httpClient) call sites switch to github.NewClient(github.WithHTTPClient(httpClient)). main.go, all tests, the doc comment on NewMockedHTTPClient, and the README examples are updated.
  • Git.UpdateRef now takes a ref string plus a github.UpdateRef value (was *Reference + force bool). TestUpdateGitReference is updated.

The other v87 breaking changes (GetConsumedLicensesListConsumedLicenses, GetAllRepositoryRulesetsListAllRepositoryRulesets, GetRulesForBranchListRulesForBranch, IssueRequest.IssueFieldValues shape) are go-github method renames and don't affect this repo, since endpoint patterns are derived from URL paths, not method names.

Downstream consumers will need to update their own github.NewClient(mockClient) calls to github.NewClient(github.WithHTTPClient(mockClient)) when bumping. The README now demonstrates this pattern.

Generator fix for hyphenated path parameters

While regenerating, FormatToGolangVarName produced names containing literal } characters for paths with hyphenated parameters (new in v87, e.g. {enterprise-team}). The old logic did strings.ReplaceAll(pattern, "-", "/") across the whole URL, which split {enterprise-team} into the broken parts {enterprise and team}.

The generator now:

  1. Splits the URL by / first.
  2. Treats - and _ as word separators inside both non-parameter segments and parameter names.

So /enterprises/{enterprise}/teams/{enterprise-team}/memberships now produces GetEnterprisesTeamsMembershipsByEnterpriseByEnterpriseTeam. Behaviour for existing patterns is unchanged. Regression tests cover the hyphenated-parameter and mutated-parameter ({path:.*}) cases.

Generated diff

src/mock/endpointpattern.go: +1542 / −402 lines. New endpoints include the Copilot coding agent (/agents/*), enterprise Copilot metrics/policies, enterprise teams, the new attestations and campaigns APIs, expanded code-security configuration endpoints, secret-scanning push protection bypass, etc. Removals reflect endpoints retired between v73 and v87 of the spec.

Verification

go vet ./...
go test ./...

both pass locally on Go 1.26.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Bumps the go-github dependency from v73 to v87 (latest) and
regenerates endpoint patterns from the latest GitHub OpenAPI
description.

Breaking changes in go-github v87 required minor source updates:

* github.NewClient now uses a functional-options pattern and returns
  (*Client, error). All NewClient(httpClient) call sites switch to
  NewClient(github.WithHTTPClient(httpClient)). README and doc
  examples updated to match.
* Git.UpdateRef now takes a ref string plus a github.UpdateRef value
  (instead of *Reference + force bool). The TestUpdateGitReference
  test is updated accordingly.

While regenerating, the var-name generator produced names containing
literal '}' characters for paths with hyphenated parameters such as
'{enterprise-team}' (new in v87). FormatToGolangVarName now splits
the path by '/' before processing and treats '-' and '_' as word
separators inside both path segments and parameter names, so
'/enterprises/{enterprise}/teams/{enterprise-team}/memberships' now
generates 'GetEnterprisesTeamsMembershipsByEnterpriseByEnterpriseTeam'.
Regression tests cover the hyphenated and mutated-parameter cases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@migueleliasweb
Copy link
Copy Markdown
Owner

Thanks for the PR @SamMorrowDrums . I'll review it tonight.

SamMorrowDrums and others added 2 commits May 19, 2026 11:31
Replace the inline `c, _ := github.NewClient(github.WithHTTPClient(...))`
pattern in the test suite with a `MustNewGHClient(t, httpClient)` helper
that fails the test if client construction returns an error, instead of
silently discarding it.

Mirrors the `mustNewGHClient` helper used in github/github-mcp-server
after its own go-github options-pattern transition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

2 participants