git

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearStoredHead

func ClearStoredHead(repoPath string) error

func Close

func Close(r *Repository) error

closing repo and release lock.

func ConflictedFiles

func ConflictedFiles(r *Repository) ([]string, error)

func GetFileAtCommit

func GetFileAtCommit(r *Repository, commitSHA string, filePath string) ([]byte, error)

GetFileAtCommit : returns the raw content of a file as it existed at a specific commit this is the most important function in this file for conflict resolution conflict/classifier.go calls this to get the three versions of a conflicted file: base version, our version, their version

func GetStoredHead

func GetStoredHead(repoPath string) (string, error)

func IsConflicted

func IsConflicted(r *Repository, filePath string) (bool, error)

func ListChangedFiles

func ListChangedFiles(r *Repository, commitSHA string) ([]string, error)

ListChangedFiles returns which files were modified in a given commit compared to its parent commit index.go uses this to know which files need conflict checking

func MarkResolved

func MarkResolved(r *Repository, filePath string) error

func ScanForMarkers added in v1.1.1

func ScanForMarkers(repoPath string) ([]string, error)

func StoreHead

func StoreHead(repoPath string, head string) error

Types

type Commit

type Commit struct {
	SHA     string
	Tree    string
	Parent  string
	Author  string
	Message string
	Time    string
}

Commit represents a single git commit object uppercase fields = public, other packages can read them

func GetCommit

func GetCommit(r *Repository, sha string) (Commit, error)

GetCommit fetches and parses a commit object by its SHA every other package in gitresolve calls this to read commit history

func GetParentCommit

func GetParentCommit(r *Repository, sha string) (Commit, error)

GetParentCommit fetches the commit that came before the given commit merge/base.go uses this to walk backwards through history to find the merge base

type Hunk

type Hunk struct {
	StartLine  int
	EndLine    int
	Kind       HunkKind
	BaseLines  []string
	OurLines   []string
	TheirLines []string
}

Hunk is one region of change between file versions

func FileDiff

func FileDiff(a, b []byte) ([]Hunk, error)

FileDiff is a simple two-way diff between any two file versions

func ThreeWayDiff

func ThreeWayDiff(base, ours, theirs []byte) ([]Hunk, error)

ThreeWayDiff compares base/ours/theirs and returns all changed regions this function splits content into lines and orchestrates the comparison

type HunkKind

type HunkKind int

HunkKind describes what kind of change a hunk represents

const (
	HunkIdentical HunkKind = iota // both sides unchanged
	HunkOursOnly
	HunkTheirsOnly
	HunkConflict
)

type Repository

type Repository struct {
	Path string
	// contains filtered or unexported fields
}

func Open

func Open(path string) (*Repository, error)

opening git repo at given path and aquire lock.

func (*Repository) HeadCommit

func (r *Repository) HeadCommit() (string, error)

fetching sha of head commit

func (*Repository) IsClean

func (r *Repository) IsClean() (bool, error)

checking if the working directory has no uncommitted changes useful to warn the user before gitresolve starts modifying files

func (*Repository) ResetHardTo

func (r *Repository) ResetHardTo(commitSHA string) error

type TreeEntry

type TreeEntry struct {
	Mode string
	Name string
	SHA  string
	Type string
}

TreeEntry : one item inside a git tree object can be either a file (blob) or a directory (another tree) "100644" = file, "040000" = directory, "100755" = executable

Jump to

Keyboard shortcuts

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