Help us shape the future of Go! Take the 2026 Go Developer Survey

common

package
v0.0.85 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGitAuthor = "colony2.com <col2bot@colony2.com>"

Variables

View Source
var ErrNotFastForward = errors.New("not a fast-forward update")

Functions

func CommitExists

func CommitExists(ctx context.Context, repoPath, commitHash string) bool

CommitExists checks if a commit exists in the repository

func EnsureCleanAfterRestore

func EnsureCleanAfterRestore(ctx context.Context, repoPath, scope, targetCommit string) error

func EnsureGitIdentity added in v0.0.84

func EnsureGitIdentity(ctx context.Context, repoPath string) error

EnsureGitIdentity fills missing identity fields in this repository only. Git's explicit author/committer environment variables retain their precedence.

func ExecuteGitCommand

func ExecuteGitCommand(ctx context.Context, repoPath string, args ...string) ([]byte, error)

ExecuteGitCommand runs a git command with context

func FindGitRoot

func FindGitRoot(path string) (string, error)

FindGitRoot returns the root directory of the git repository

func GetCommitHash

func GetCommitHash(ctx context.Context, repoPath, ref string) (string, error)

GetCommitHash returns the full commit hash for a given ref

func GitAuthorForCell added in v0.0.63

func GitAuthorForCell(string) string

GitAuthorForCell uses the same bot fallback for every cell.

func HeadCommit added in v0.0.84

func HeadCommit(ctx context.Context, repoPath string, allowUnborn bool) (string, error)

HeadCommit permits an unborn symbolic HEAD only when explicitly requested.

func IsRemoteRepository

func IsRemoteRepository(source string) bool

IsRemoteRepository reports whether the provided source string looks like a git remote (e.g. ssh/https/file URLs or the SCP-like "git@host:org/repo.git" syntax).

func PrepareScopedCommit

func PrepareScopedCommit(ctx context.Context, repoPath, scope string) (bool, error)

PrepareScopedCommit resets staged changes outside the provided scope, cleans untracked files, and stages the scoped path. It returns true when the scope produces staged changes.

func ValidateRepository

func ValidateRepository(repoPath string) error

ValidateRepository checks if path is within a valid Git repository

Types

type GitConfig

type GitConfig struct {
	Author  string        `json:"author,omitempty"`
	Email   string        `json:"email,omitempty"`
	Timeout time.Duration `json:"timeout,omitempty"`
}

GitConfig contains common Git configuration

type NotFastForwardError

type NotFastForwardError struct {
	TargetBranch string
	LocalHead    string
	UpstreamHead string
}

func (NotFastForwardError) Error

func (e NotFastForwardError) Error() string

func (NotFastForwardError) Is

func (e NotFastForwardError) Is(target error) bool

type ThinPackMetadata

type ThinPackMetadata struct {
	CommitHash string    `json:"commit_hash"`
	ParentHash string    `json:"parent_hash"`
	RootHash   string    `json:"root_hash"`
	FilePath   string    `json:"file_path"`
	Size       int64     `json:"size"`
	CreatedAt  time.Time `json:"created_at"`
}

ThinPackMetadata describes a thin pack file

func ParseThinPackName

func ParseThinPackName(filename string) (*ThinPackMetadata, error)

ParseThinPackName extracts metadata from thin pack filename

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL