Repository navigation
Conversation
Member
|
Thanks for your interest in palantir/go-githubapp, @Mattbusel! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Generate changelog in
|
Both functions only read the repository name and owner login, but took a *github.Repository, so handlers for push events had to convert a *github.PushEventRepository first. Take a small RepositoryInfo interface (GetName, GetOwner) instead, which *github.Repository and *github.PushEventRepository both satisfy. Existing callers compile unchanged. A nil repository, typed or untyped, still adds no repository log keys. Fixes palantir#75
Mattbusel
force-pushed
the
repo-context-interface
branch
from
November 18, 2026 00:33
c8249e7 to
044c027
Compare
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.
Fixes #75.
Before this PR
PrepareRepoContextandPreparePRContexttook a*github.Repositorybut only read the name and owner login. Handlers for push events, which carry a*github.PushEventRepository, had to build a*github.Repositoryjust to get the log keys.After this PR
==COMMIT_MSG==
PrepareRepoContextandPreparePRContextaccept any repository type withGetNameandGetOwner, including*github.PushEventRepository, through a newRepositoryInfointerface.==COMMIT_MSG==
RepositoryInfohas the two getters the functions use; compile-time assertions check that*github.Repositoryand*github.PushEventRepositorysatisfy it. The name is a suggestion, happy to rename.attachRepoLogKeysskips a repository with no owner and no name, which covers(*github.Repository)(nil)and(*github.PushEventRepository)(nil).*github.Repository, typed*github.PushEventRepository).go vet ./...andgo test ./...pass.Possible downsides?
Code that stores these functions in a variable typed with the old signature (
func(context.Context, int64, *github.Repository) ...) would need to update that type. Direct calls are unaffected. A non-nil repository with neither a name nor an owner no longer gets two empty log keys.Prepared with AI assistance (Claude); the change and tests were run locally before opening.