git

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMetrics

func InitMetrics(registerer prometheus.Registerer)

Types

type Client

type Client struct {
	RepoURL string

	Branch string

	SSHKey string

	RepoPath string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(repoURL, branch, sshKey string) *Client

func NewClientFromConfig

func NewClientFromConfig(config *ClientConfig) *Client

func NewClientWithLogger

func NewClientWithLogger(repoURL, branch, sshKey string, logger *slog.Logger) *Client

func (*Client) Add

func (c *Client) Add(path string) error

func (*Client) AddRemote

func (c *Client) AddRemote(name, url string) error

func (*Client) ApplyPatch

func (c *Client) ApplyPatch(patch string) error

func (*Client) ApprovePullRequest

func (c *Client) ApprovePullRequest(id int) error

func (*Client) CherryPick

func (c *Client) CherryPick(commitHash string) error

func (*Client) Clean

func (c *Client) Clean(force bool) error

func (*Client) CommitAndPush

func (c *Client) CommitAndPush(files map[string]string, message string) (string, error)

func (*Client) CommitAndPushChanges

func (c *Client) CommitAndPushChanges(message string) error

func (*Client) CommitFiles

func (c *Client) CommitFiles(files []string, msg string) error

func (*Client) CreateBranch

func (c *Client) CreateBranch(name string) error

func (*Client) CreatePatch

func (c *Client) CreatePatch(options DiffOptions) (string, error)

func (*Client) CreatePullRequest

func (c *Client) CreatePullRequest(options PullRequestOptions) (PullRequestInfo, error)

func (*Client) CreateTag

func (c *Client) CreateTag(name, message string) error

func (*Client) DeleteBranch

func (c *Client) DeleteBranch(name string) error

func (*Client) Fetch

func (c *Client) Fetch(remote string) error

func (*Client) GetCommitHistory

func (c *Client) GetCommitHistory(options LogOptions) ([]CommitInfo, error)

func (*Client) GetCurrentBranch

func (c *Client) GetCurrentBranch() (string, error)

func (*Client) GetDiff

func (c *Client) GetDiff(options DiffOptions) (string, error)

func (*Client) GetFileContent

func (c *Client) GetFileContent(path string) ([]byte, error)

func (*Client) GetLog

func (c *Client) GetLog(options LogOptions) ([]CommitInfo, error)

func (*Client) GetPullRequestStatus

func (c *Client) GetPullRequestStatus(id int) (string, error)

func (*Client) GetRemotes

func (c *Client) GetRemotes() ([]RemoteInfo, error)

func (*Client) GetStatus

func (c *Client) GetStatus() ([]StatusInfo, error)

func (*Client) GetTagInfo

func (c *Client) GetTagInfo(name string) (TagInfo, error)

func (*Client) InitRepo

func (c *Client) InitRepo() error

func (*Client) ListBranches

func (c *Client) ListBranches() ([]string, error)

func (*Client) ListTags

func (c *Client) ListTags() ([]TagInfo, error)

func (*Client) MergeBranch

func (c *Client) MergeBranch(sourceBranch, targetBranch string) error

func (*Client) MergePullRequest

func (c *Client) MergePullRequest(id int) error

func (*Client) Move

func (c *Client) Move(oldPath, newPath string) error

func (*Client) Pull

func (c *Client) Pull(remote string) error

func (*Client) Push

func (c *Client) Push(remote string) error

func (*Client) RebaseBranch

func (c *Client) RebaseBranch(sourceBranch, targetBranch string) error

func (*Client) Remove

func (c *Client) Remove(path string) error

func (*Client) RemoveDirectory

func (c *Client) RemoveDirectory(path string, commitMessage string) error

func (*Client) RemoveRemote

func (c *Client) RemoveRemote(name string) error

func (*Client) Reset

func (c *Client) Reset(options ResetOptions) error

func (*Client) Restore

func (c *Client) Restore(path string) error

func (*Client) SwitchBranch

func (c *Client) SwitchBranch(name string) error

type ClientConfig

type ClientConfig struct {
	RepoURL string

	Branch string

	Token string // Token loaded from file or environment

	TokenPath string // Optional path to token file

	RepoPath string

	Logger *slog.Logger

	ConcurrentPushLimit int // Maximum concurrent git operations (default 4 if <= 0)
}

func NewGitClientConfig

func NewGitClientConfig(repoURL, branch, token, tokenPath string) (*ClientConfig, error)

type ClientInterface

type ClientInterface interface {
	CommitAndPush(files map[string]string, message string) (string, error)

	CommitAndPushChanges(message string) error

	InitRepo() error

	RemoveDirectory(path string, commitMessage string) error

	CommitFiles(files []string, msg string) error

	CreateBranch(name string) error

	SwitchBranch(name string) error

	GetCurrentBranch() (string, error)

	ListBranches() ([]string, error)

	GetFileContent(path string) ([]byte, error)
}

type CommitInfo

type CommitInfo struct {
	Hash string

	Message string

	Author string

	Email string

	Timestamp time.Time
}

type DiffOptions

type DiffOptions struct {
	Cached bool

	NameOnly bool

	Stat bool

	Source string

	Target string

	Path string
}

type LogOptions

type LogOptions struct {
	Limit int

	Since *time.Time

	Until *time.Time

	Author string

	Grep string

	OneLine bool

	Graph bool

	Path string
}

type PullRequestInfo

type PullRequestInfo struct {
	ID int

	Number int

	Title string

	Description string

	State string // open, closed, merged

	SourceBranch string

	TargetBranch string

	Author string

	URL string

	CreatedAt time.Time

	UpdatedAt time.Time
}

type PullRequestOptions

type PullRequestOptions struct {
	Title string

	Description string

	SourceBranch string

	TargetBranch string

	Labels []string

	Assignees []string
}

type RemoteInfo

type RemoteInfo struct {
	Name string

	URL string

	Type string // fetch, push
}

type ResetOptions

type ResetOptions struct {
	Mode string // soft, mixed, hard

	Target string // commit hash, branch, tag
}

type StatusInfo

type StatusInfo struct {
	Path string

	Status string // Modified, Added, Deleted, Untracked, etc.

	Staging string // Status in staging area

	Worktree string // Status in working tree
}

type TagInfo

type TagInfo struct {
	Name string

	Hash string

	Message string

	Author string

	Email string

	Timestamp time.Time
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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