Release Notes v0.3.0¶
This is a major release that restructures the gogithub package into modular subpackages organized by operation type, significantly expanding functionality while maintaining backward compatibility.
Highlights¶
- Modular architecture: Reorganized from a flat package into focused subpackages (
auth,search,repo,pr,release, etc.) - New functionality: Added comprehensive support for repository operations, pull requests, releases, and batch commits
- Error handling: New
errorspackage with standard error types and translation utilities - Configuration: New
configpackage with environment variable support and GitHub Enterprise support - Updated dependencies: go-github upgraded from v68 to v81
New Packages¶
auth/ - Authentication Utilities¶
NewGitHubClient(ctx, token)- Create authenticated GitHub clientNewTokenClient(ctx, token)- Create authenticated HTTP clientGetAuthenticatedUser(ctx, client)- Get current user's loginGetUser(ctx, client, username)- Get user informationAuthError- Authentication error type
search/ - Search API¶
Client- Search client with pagination supportSearchIssues/SearchIssuesAll- Search issues with automatic paginationSearchOpenPullRequests- Convenience method for PR searchQuery- Query builder with parameter constantsIssues/Issue- Result types with table generation support
repo/ - Repository Operations¶
Fork and branch operations (fork.go, branch.go):
EnsureFork- Ensure a fork exists, creating if neededGetDefaultBranch- Get repository's default branchCreateBranch/DeleteBranch/BranchExists- Branch managementGetBranchSHA- Get SHA of a branch
Commit operations (commit.go):
CreateCommit- Create commits using Git tree APIReadLocalFiles- Read local files for commitFileContent- File content type for commits
Listing operations (list.go):
ListOrgRepos/ListUserRepos- List repositories with paginationGetRepo- Get repository detailsParseRepoName- Parse "owner/repo" format
Batch operations (batch.go):
Batch- Accumulate multiple file operations for atomic commitsNewBatch- Create batch with optionsWrite/Delete- Queue file operationsCommit- Apply all operations in a single commitWithCommitAuthor- Set commit author option
pr/ - Pull Request Operations¶
CreatePR- Create pull requestsGetPR/ListPRs- Retrieve pull requestsMergePR/ClosePR- Merge or close PRsAddPRReviewers- Request reviewersListPRFiles/ListPRComments- List PR files and commentsPRError- PR operation error type
release/ - Release Operations¶
ListReleases/ListReleasesSince- List releases with paginationGetRelease/GetLatestRelease/GetReleaseByTag- Get release detailsListReleaseAssets- List release assets
errors/ - Error Types and Translation¶
- Standard errors:
ErrNotFound,ErrPermissionDenied,ErrRateLimited,ErrConflict,ErrValidation,ErrServerError APIError- Wrapper with status code and contextTranslate- Convert GitHub API errors to standard errors- Helper functions:
IsNotFound,IsPermissionDenied,IsRateLimited, etc. StatusCode- Extract HTTP status from errors
config/ - Configuration Utilities¶
Config- Configuration struct with validationFromEnv/FromEnvWithConfig- Load from environment variablesFromMap- Load from string mapNewClient/MustNewClient- Create clients from config- GitHub Enterprise support via
BaseURLandUploadURL EnvConfig- Customizable environment variable names
pathutil/ - Path Utilities¶
Validate- Validate paths for GitHub APINormalize- Normalize paths (clean, remove leading slashes)ValidateAndNormalize- Combined operationJoin/Split/Dir/Base/Ext- Path manipulationHasPrefix- Check path prefix- Protection against path traversal attacks
cliutil/ - CLI Utilities¶
GitStatusShortLines- Get git status outputGitRmDeletedLines- Generate git rm commands for deleted filesGitRmDeletedFile- Write git rm commands to file
Backward Compatibility¶
The root gogithub package provides backward-compatible re-exports:
// Old style (still works)
import "github.com/grokify/gogithub"
c := gogithub.NewClient(httpClient)
issues, _ := c.SearchIssuesAll(ctx, gogithub.Query{...}, nil)
// New style (preferred)
import (
"github.com/grokify/gogithub/auth"
"github.com/grokify/gogithub/search"
)
gh := auth.NewGitHubClient(ctx, token)
c := search.NewClient(gh)
issues, _ := c.SearchIssuesAll(ctx, search.Query{...}, nil)
Re-exported types and constants:
Query,Issues,IssuetypesParamUser,ParamState,ParamStateValueOpen,ParamIs,ParamIsValuePR,ParamPerPageValueMaxUsernameDependabot,UserIDDependabotBaseURLRepoAPI,BaseURLRepoHTML
Deprecated methods (still available on Client):
SearchOpenPullRequestsSearchIssuesSearchIssuesAll
Breaking Changes¶
- Recommended import path: While backward compatible, new code should import from subpackages
- Removed files:
api_search.go(moved tosearch/)constants.go(moved tosearch/)issue.go(moved tosearch/)pullrequest/directory (moved topr/andcmd/)
Dependency Updates¶
github.com/google/go-githubupgraded from v68 to v81- Go version updated to 1.24.0
Migration Guide¶
- No immediate action required: Existing code using the root package will continue to work
- Gradual migration: Update imports to use subpackages for new code
- Full migration: Replace root package imports with specific subpackages
Example migration:
// Before
import "github.com/grokify/gogithub"
c := gogithub.NewClient(httpClient)
result, resp, err := c.SearchIssues(ctx, gogithub.Query{
gogithub.ParamUser: "grokify",
}, nil)
// After
import (
"github.com/grokify/gogithub/auth"
"github.com/grokify/gogithub/search"
)
gh := auth.NewGitHubClient(ctx, token)
c := search.NewClient(gh)
result, resp, err := c.SearchIssues(ctx, search.Query{
search.ParamUser: "grokify",
}, nil)