Documentation
¶
Overview ¶
Package git provides version control operations for commits, tags, branches, and PRs.
Index ¶
- func CommitAndRelease(ctx context.Context, bump VersionBump) error
- func CommitCompletedFile(ctx context.Context, path string) error
- func GetNextVersion(ctx context.Context, bump VersionBump) (string, error)
- func MoveFile(ctx context.Context, oldPath string, newPath string) error
- func ResolveGitRoot(ctx context.Context) (string, error)
- type Brancher
- type Cloner
- type CollaboratorFetcher
- type CollaboratorLister
- type PRCreator
- type PRMerger
- type Releaser
- type RepoNameFetcher
- type ReviewFetcher
- type ReviewResult
- type ReviewVerdict
- type SemanticVersionNumber
- type VersionBump
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CommitAndRelease ¶
func CommitAndRelease(ctx context.Context, bump VersionBump) error
CommitAndRelease performs the full git workflow: 1. git add -A 2. Read CHANGELOG.md and rename ## Unreleased to version 3. Bump version (patch or minor) 4. git commit 5. git tag 6. git push + push tag
func CommitCompletedFile ¶ added in v0.2.27
CommitCompletedFile stages and commits a completed prompt file. This is called after MoveToCompleted() to ensure the moved file is committed. Does nothing if the file is already staged or committed.
func GetNextVersion ¶ added in v0.2.0
func GetNextVersion(ctx context.Context, bump VersionBump) (string, error)
GetNextVersion determines the next version based on the bump type.
Types ¶
type Brancher ¶ added in v0.9.0
type Brancher interface {
CreateAndSwitch(ctx context.Context, name string) error
Push(ctx context.Context, name string) error
Switch(ctx context.Context, name string) error
CurrentBranch(ctx context.Context) (string, error)
Fetch(ctx context.Context) error
FetchAndVerifyBranch(ctx context.Context, branch string) error
DefaultBranch(ctx context.Context) (string, error)
Pull(ctx context.Context) error
MergeOriginDefault(ctx context.Context) error
}
Brancher handles git branch operations.
type Cloner ¶ added in v0.30.4
type Cloner interface {
Clone(ctx context.Context, srcDir string, destDir string, branch string) error
Remove(ctx context.Context, path string) error
}
Cloner handles local git clone operations.
type CollaboratorFetcher ¶ added in v0.30.12
CollaboratorFetcher fetches GitHub repository collaborators.
func NewCollaboratorFetcher ¶ added in v0.30.12
func NewCollaboratorFetcher( repoNameFetcher RepoNameFetcher, collaboratorLister CollaboratorLister, useCollaborators bool, allowedReviewers []string, ) CollaboratorFetcher
NewCollaboratorFetcher creates a CollaboratorFetcher. If useCollaborators is false or allowedReviewers is non-empty, collaborators are not fetched from GitHub.
type CollaboratorLister ¶ added in v0.30.15
CollaboratorLister lists collaborator logins for a GitHub repository.
func NewGHCollaboratorLister ¶ added in v0.30.15
func NewGHCollaboratorLister(ghToken string) CollaboratorLister
NewGHCollaboratorLister creates a CollaboratorLister that uses gh CLI.
type PRCreator ¶ added in v0.9.0
PRCreator handles GitHub pull request creation.
func NewPRCreator ¶ added in v0.9.0
NewPRCreator creates a new PRCreator.
type PRMerger ¶ added in v0.17.6
PRMerger watches a PR until mergeable and merges it.
func NewPRMerger ¶ added in v0.17.6
NewPRMerger creates a new PRMerger.
type Releaser ¶ added in v0.2.26
type Releaser interface {
GetNextVersion(ctx context.Context, bump VersionBump) (string, error)
CommitAndRelease(ctx context.Context, bump VersionBump) error
CommitCompletedFile(ctx context.Context, path string) error
CommitOnly(ctx context.Context, message string) error
HasChangelog(ctx context.Context) bool
MoveFile(ctx context.Context, oldPath string, newPath string) error
}
Releaser handles git commit, tag, and push operations.
type RepoNameFetcher ¶ added in v0.30.15
RepoNameFetcher fetches the current GitHub repository name with owner.
func NewGHRepoNameFetcher ¶ added in v0.30.15
func NewGHRepoNameFetcher(ghToken string) RepoNameFetcher
NewGHRepoNameFetcher creates a RepoNameFetcher that uses gh CLI.
type ReviewFetcher ¶ added in v0.17.35
type ReviewFetcher interface {
// FetchLatestReview returns the latest review from a trusted reviewer.
// Returns ReviewVerdictNone if no trusted review exists yet.
FetchLatestReview(
ctx context.Context,
prURL string,
allowedReviewers []string,
) (*ReviewResult, error)
// FetchPRState returns the raw PR state string: "OPEN", "MERGED", "CLOSED".
FetchPRState(ctx context.Context, prURL string) (string, error)
}
ReviewFetcher polls a GitHub PR for reviews from trusted reviewers.
func NewReviewFetcher ¶ added in v0.17.35
func NewReviewFetcher(ghToken string) ReviewFetcher
NewReviewFetcher creates a new ReviewFetcher.
type ReviewResult ¶ added in v0.17.35
type ReviewResult struct {
Verdict ReviewVerdict
Body string // full review body text
}
ReviewResult holds the latest review from a trusted reviewer.
type ReviewVerdict ¶ added in v0.17.35
type ReviewVerdict string
ReviewVerdict represents the outcome of a PR review.
const ( ReviewVerdictNone ReviewVerdict = "" ReviewVerdictApproved ReviewVerdict = "approved" ReviewVerdictChangesRequested ReviewVerdict = "changes_requested" )
type SemanticVersionNumber ¶ added in v0.2.33
SemanticVersionNumber represents a parsed semantic version.
func ParseSemanticVersionNumber ¶ added in v0.2.33
func ParseSemanticVersionNumber(ctx context.Context, tag string) (SemanticVersionNumber, error)
ParseSemanticVersionNumber parses "vX.Y.Z" into a SemanticVersionNumber. Returns error if format is invalid.
func (SemanticVersionNumber) BumpMinor ¶ added in v0.2.33
func (v SemanticVersionNumber) BumpMinor() SemanticVersionNumber
BumpMinor returns a new version with minor incremented and patch reset to 0.
func (SemanticVersionNumber) BumpPatch ¶ added in v0.2.33
func (v SemanticVersionNumber) BumpPatch() SemanticVersionNumber
BumpPatch returns a new version with patch incremented.
func (SemanticVersionNumber) Less ¶ added in v0.2.33
func (v SemanticVersionNumber) Less(other SemanticVersionNumber) bool
Less returns true if v is lower than other.
func (SemanticVersionNumber) String ¶ added in v0.2.33
func (v SemanticVersionNumber) String() string
String returns the "vX.Y.Z" representation.
type VersionBump ¶ added in v0.2.30
type VersionBump int
VersionBump specifies the type of version bump to perform.
const ( // PatchBump increments the patch version (vX.Y.Z -> vX.Y.Z+1) PatchBump VersionBump = iota // MinorBump increments the minor version (vX.Y.Z -> vX.Y+1.0) MinorBump )