casgit

package
v0.1.23-oss Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RepoPacksDir = "packs"
	RepoDirName  = ".repo"
)

Variables

View Source
var (
	ErrWalkStop     = errors.New("stop the walk")
	ErrWalkNoStepIn = errors.New("do not step into dir")
)

Functions

func EncodedObjectHeader

func EncodedObjectHeader(encoded plumbing.EncodedObject) string

func FindGitDir

func FindGitDir(startDir string) (string, error)

func NewDeepTreeDir

func NewDeepTreeDir(git *CASGit, deepTree *gitobjects.DeepTreeObject) gitindex.TreeDirectory

NewDeepTreeDir creates a TreeDirectory root from a DeepTreeObject.

func RefSpecsMatch

func RefSpecsMatch(ref string, specs []RefSpec) (string, bool)

RefSpecsMatch determines if the given reference matches the provided list of RefSpecs. A reference is considered matching if:

  1. It does not match any negative RefSpec.
  2. Either no positive specs are specified or it matches at least one positive RefSpec.

func RefSpecsPrefix

func RefSpecsPrefix(specs []RefSpec) string

func SetupCentralCommitMsgHook

func SetupCentralCommitMsgHook(ctx context.Context, store entities.CASStore, casfs bindcas.CASFS, repoRoot string)

func Walk

func Walk(ctx context.Context, dirHash entities.Hash, store entities.CASStore, visit WalkFunc) error

func WriteFileAtomic

func WriteFileAtomic(filename string, data []byte, perm os.FileMode) (retErr error)

func WriteGitConfig

func WriteGitConfig(gitDir string, cfg *GitConfig) error

Types

type Branch

type Branch struct {
	Name        string
	Remote      string
	Merge       string
	Rebase      bool
	PushRemote  string
	Description string
}

func (*Branch) TrackingRef

func (b *Branch) TrackingRef() string

type CASGit

type CASGit struct {
	// contains filtered or unexported fields
}

func New

func New(casStore entities.CASStore) *CASGit

func NewWithCASFS

func NewWithCASFS(casStore entities.CASStore, casfs bindcas.CASFS) *CASGit

func NewWithClient

func NewWithClient(client *binding.Client, cacheman *client.Client) *CASGit

func (*CASGit) Checkout

func (g *CASGit) Checkout(ctx context.Context, opts CheckoutOptions) error

func (*CASGit) Clone

func (g *CASGit) Clone(ctx context.Context, opts CloneOptions) error

func (*CASGit) Fetch

func (g *CASGit) Fetch(ctx context.Context, opts FetchOptions) error

func (CASGit) GetCommit

func (g CASGit) GetCommit(ctx context.Context, key entities.Hash) (*object.Commit, error)

func (*CASGit) GetSymRef

func (g *CASGit) GetSymRef(ctx context.Context, server string, project string, ref string) (string, error)

func (CASGit) ResolveCommit

func (g CASGit) ResolveCommit(ctx context.Context, key entities.Hash) (*object.Commit, error)

ResolveCommit will return the Commit object for a hash referencing a commit or a tag

func (*CASGit) ResolveRef

func (g *CASGit) ResolveRef(ctx context.Context, server, project, ref string) (entities.Hash, string, error)

func (*CASGit) WriteIndexFromCASFS

func (g *CASGit) WriteIndexFromCASFS(workDir string, commitHash entities.Hash, indexFilePath string) error

func (*CASGit) WriteIndexFromDeepTree

func (g *CASGit) WriteIndexFromDeepTree(workDir string, deepTree *gitobjects.DeepTreeObject, indexFilePath string) error

type CheckoutOptions

type CheckoutOptions struct {
	Target string
	Paths  []string

	NewBranch      string
	NewBranchForce string
	Orphan         string

	Track       string
	NoTrack     bool
	GuessRemote bool
	NoGuess     bool

	Detach bool

	Force         bool
	Merge         bool
	ConflictStyle string
	Quiet         bool
	Progress      bool
	NoProgress    bool

	Theirs bool
	Ours   bool
	Patch  bool

	Overlay   bool
	NoOverlay bool

	PathspecFromFile string
	PathspecFileNUL  bool

	RecurseSubmodules      string
	NoRecurseSubmodules    bool
	IgnoreSkipWorktreeBits bool
	IgnoreOtherWorktrees   bool

	GitDir    string
	ObjectDir string
	WorkDir   string
}

type CloneOptions

type CloneOptions struct {
	RemoteRepo       string
	Directory        string
	Origin           string
	Commit           entities.Hash
	TreeHash         entities.Hash
	Branch           string
	SingleBranch     bool
	NoTags           bool
	GitDir           string
	ObjectsDir       string
	Quiet            bool
	KeepOnFail       bool
	PrefetchIndices  bool
	PrefetchSymlinks bool
	DetachedHead     bool
}

type ConfigGroup

type ConfigGroup struct {
	Name   string
	Keys   []string
	Values []string
}

type FetchOptions

type FetchOptions struct {
	Remote    string
	RefSpecs  []string
	All       bool
	Prune     bool
	NoTags    bool
	Tags      bool
	GitDir    string
	ObjectDir string
	Quiet     bool
	Verbose   bool
}

type GitCheckout

type GitCheckout struct {
	CheckoutOptions
	*GitRepo
	// contains filtered or unexported fields
}

func (*GitCheckout) Checkout

func (c *GitCheckout) Checkout(ctx context.Context) error

type GitClone

type GitClone struct {
	CloneOptions
	*GitRepo
	// contains filtered or unexported fields
}

type GitConfig

type GitConfig struct {
	// contains filtered or unexported fields
}

func ParseGitConfig

func ParseGitConfig(r io.Reader) (*GitConfig, error)

func ReadGitConfig

func ReadGitConfig(gitDir string) (*GitConfig, error)

func (*GitConfig) Add

func (c *GitConfig) Add(key, value string) error

func (*GitConfig) Get

func (c *GitConfig) Get(key string) (string, bool, error)

func (*GitConfig) GetAll

func (c *GitConfig) GetAll(key string) ([]string, error)

func (*GitConfig) Group

func (c *GitConfig) Group(prefix string) []ConfigGroup

func (*GitConfig) KeysWithPrefix

func (c *GitConfig) KeysWithPrefix(prefix string) []string

func (*GitConfig) Set

func (c *GitConfig) Set(key, value string) error

func (*GitConfig) Unset

func (c *GitConfig) Unset(key string) error

func (*GitConfig) Write

func (c *GitConfig) Write(w io.Writer) error

type GitFetch

type GitFetch struct {
	FetchOptions
	*GitRepo
	// contains filtered or unexported fields
}

func (*GitFetch) Fetch

func (f *GitFetch) Fetch(ctx context.Context) error

type GitRepo

type GitRepo struct {
	// contains filtered or unexported fields
}

func NewGitRepo

func NewGitRepo(casgit *CASGit, workDir, gitDir, objectsDir string) *GitRepo

func (*GitRepo) AddConfig

func (r *GitRepo) AddConfig(key, value string) error

func (*GitRepo) CurrentBranch

func (r *GitRepo) CurrentBranch() (*Branch, error)

func (*GitRepo) DiffHeadTree

func (r *GitRepo) DiffHeadTree(ctx context.Context, treeHash entities.Hash) ([]dirsync.DiffAction, error)

func (*GitRepo) DiffHeadWorkDir

func (r *GitRepo) DiffHeadWorkDir(ctx context.Context) ([]dirsync.DiffAction, error)

func (*GitRepo) GetAllConfig

func (r *GitRepo) GetAllConfig(key string) ([]string, error)

func (*GitRepo) GetBranch

func (r *GitRepo) GetBranch(name string) *Branch

func (*GitRepo) GetConfig

func (r *GitRepo) GetConfig(key, defaultValue string) (string, error)

func (*GitRepo) GetRemote

func (r *GitRepo) GetRemote(remote string) (*Remote, error)

func (*GitRepo) HasUncommitedChanges

func (r *GitRepo) HasUncommitedChanges() (bool, error)

func (*GitRepo) IsDetached

func (r *GitRepo) IsDetached() bool

func (*GitRepo) Load

func (r *GitRepo) Load() error

func (*GitRepo) LoadConfig

func (r *GitRepo) LoadConfig() (retErr error)

func (*GitRepo) LocalCommits

func (r *GitRepo) LocalCommits(branchName string) ([]string, error)

func (*GitRepo) Project

func (r *GitRepo) Project() string

func (*GitRepo) RebaseCommitsOnto

func (r *GitRepo) RebaseCommitsOnto(projectName string, localCommits []string, revision string) error

func (*GitRepo) RevParse

func (r *GitRepo) RevParse(ref string) (string, error)

func (*GitRepo) Server

func (r *GitRepo) Server() string

func (*GitRepo) SetConfig

func (r *GitRepo) SetConfig(key, value string) error

func (*GitRepo) UnsetConfig

func (r *GitRepo) UnsetConfig(key string) error

func (*GitRepo) UpdateLocalBranchToHead

func (r *GitRepo) UpdateLocalBranchToHead(projectName string, branchName string) error

type Hash

type Hash = entities.Hash

type RefSpec

type RefSpec struct {
	Source      string
	Destination string
	IsNegative  bool
	IsWildcard  bool
}

func ParseRefSpec

func ParseRefSpec(spec string) (RefSpec, error)

func ParseRefSpecs

func ParseRefSpecs(specs []string) ([]RefSpec, error)

func (RefSpec) Map

func (r RefSpec) Map(ref string) string

func (RefSpec) Match

func (r RefSpec) Match(ref string) bool

type RefUpdate

type RefUpdate struct {
	SourceRef string
	DestRef   string
	OldHash   entities.Hash
	NewHash   entities.Hash
}

func (*RefUpdate) LongFormat

func (u *RefUpdate) LongFormat() string

type Remote

type Remote struct {
	Name    string
	URL     string
	PushURL string
	Fetch   []RefSpec
	Mirror  bool
	TagOpts string
}

type WalkFunc

type WalkFunc func(path string, mode entities.FileMode, hash entities.Hash) error

Jump to

Keyboard shortcuts

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