git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package git provides Git operations for gitcode-cli

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(repo *Repo, dir string, depth int) error

Clone clones a repository to the specified directory

func CloneWithProtocol

func CloneWithProtocol(repo *Repo, dir string, protocol string, depth int) error

CloneWithProtocol clones a repository using the specified protocol

func CurrentBranch

func CurrentBranch() (string, error)

CurrentBranch returns the current branch name

func DefaultRemote

func DefaultRemote() (string, error)

DefaultRemote returns the default remote (origin or first available)

func HasLocalChanges

func HasLocalChanges() (bool, error)

HasLocalChanges returns true if there are uncommitted changes

func IsRepo

func IsRepo() bool

IsRepo returns true if current directory is a git repository

func RemoteURL

func RemoteURL(name string) (string, error)

RemoteURL returns the URL of a remote

func Remotes

func Remotes() ([]string, error)

Remotes returns the list of remote names

func RootDir

func RootDir() (string, error)

RootDir returns the root directory of the git repository

func Run

func Run(args ...string) (string, error)

Run executes a git command and returns the output

func RunInDir

func RunInDir(dir string, args ...string) (string, error)

RunInDir executes a git command in a specific directory

func RunInDirWithEnv added in v0.3.9

func RunInDirWithEnv(dir string, env map[string]string, args ...string) (string, error)

RunInDirWithEnv executes a git command in a specific directory with extra environment variables.

func RunWithEnv added in v0.3.9

func RunWithEnv(env map[string]string, args ...string) (string, error)

RunWithEnv executes a git command with extra environment variables.

Types

type Repo

type Repo struct {
	Owner string
	Name  string
	Host  string
}

Repo represents a parsed repository reference

func CurrentRepo

func CurrentRepo() (*Repo, error)

CurrentRepo returns the current repository from git remote

func ParseRepo

func ParseRepo(ref string) (*Repo, error)

ParseRepo parses a repository reference Supports formats: - owner/repo - https://gitcode.com/owner/repo - git@gitcode.com:owner/repo.git

func (*Repo) GitURL

func (r *Repo) GitURL(protocol string) string

GitURL returns the git URL for the repository

func (*Repo) String

func (r *Repo) String() string

String returns the full repository path (owner/name)

func (*Repo) URL

func (r *Repo) URL() string

URL returns the full URL for the repository

Source Files

  • git.go
  • repo.go

Jump to

Keyboard shortcuts

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