gitforge
A shared Go library providing common abstractions for working with Git hosting platforms (forges). Used by autobump and autoupdate.
Features
- Multi-Provider Support: GitHub, GitLab, Azure DevOps, and Codeberg (Forgejo) with a unified interface
- Repository Discovery: Automatically list repositories from organizations/groups
- Pull Request Management: Create PRs/MRs and check for existing ones
- File Operations: Read files, list trees, check file existence via API
- Local Git Operations: Branch, commit, push (SSH/HTTPS) via go-git
- Commit Signing: GPG signing with keyring export and passphrase support, and SSH signing via
ssh-keygen
- Changelog Processing: Full Keep-a-Changelog toolkit (version calculation, deduplication, entry insertion)
- Configuration: Token resolution (inline,
${ENV_VAR}, file path), config file discovery
- Registry Pattern: Factory-based provider and discoverer registries
Installation
go get github.com/rios0rios0/gitforge/v4
Import the packages from github.com/rios0rios0/gitforge/v4/.... Go requires a module released at v2 or later to carry its major version in the module path, so the path changes with every major release.
Architecture
Bounded contexts live under pkg/, each owning its own domain/ and infrastructure/ packages:
gitforge/
├── pkg/
│ ├── changelog/ # Keep-a-Changelog processing (version calculation, deduplication, insertion)
│ ├── config/ # YAML configuration loading, token resolution, config file discovery
│ ├── git/ # Local git operations (go-git), URL parsing, SSH/HTTPS push
│ ├── global/ # Shared interfaces (ForgeProvider, FileAccessProvider, etc.) and entities
│ ├── providers/ # GitHub, GitLab, Azure DevOps, Codeberg implementations
│ ├── registry/ # Provider and discoverer registries
│ └── signing/ # GPG and SSH commit signing
└── test/ # Shared test doubles and builders
Provider Interfaces
The library uses Go interface composition:
ForgeProvider: Core interface (URL matching, discovery, PR creation, auth)
FileAccessProvider: Extends with API-based file operations (read, list, tags, branch creation)
LocalGitAuthProvider: Extends with local go-git authentication (service type, transport, auth methods)
ReviewProvider: Extends with pull request review operations (diffs, comments, threads, merge, review submission)
MirrorProvider: Extends with repository migration/mirroring
Each concrete provider implements the first three interfaces. GitHub and Azure DevOps also implement ReviewProvider; Codeberg also implements MirrorProvider. Consumers type-assert to the level they need.
Two optional single-method interfaces sit beside that hierarchy, also reached by type assertion:
OpenPullRequestFinder (GitHub, Azure DevOps): returns the open pull request of a source branch, where PullRequestExists only reports that one exists
OrganizationRepositoryLister (Azure DevOps): lists a whole organization in one strict call and fails instead of skipping a part of it, where DiscoverRepositories stays best-effort
Discovered repositories report IsFork, IsArchived and IsDisabled (disabled, or under maintenance on Azure DevOps). Providers never filter on them; skipping such repositories is the consumer's policy.
License
See LICENSE file for details.