git

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	GitDir   string // .oops/filename.git
	WorkTree string // directory containing the file
	FileName string // the tracked file name
	// contains filtered or unexported fields
}

Repo represents a Git repository for a single file

func NewRepo

func NewRepo(gitDir, workTree, fileName string) *Repo

NewRepo creates a new Repo instance

func (*Repo) Add

func (r *Repo) Add() error

Add stages the tracked file

func (*Repo) Checkout

func (r *Repo) Checkout(tag string) error

Checkout restores a file from a specific tag

func (*Repo) CheckoutHead

func (r *Repo) CheckoutHead() error

CheckoutHead restores the file to HEAD

func (*Repo) Commit

func (r *Repo) Commit(message string) (string, error)

Commit creates a new commit with the given message

func (*Repo) Diff

func (r *Repo) Diff(refs ...string) (string, error)

Diff returns the diff between working file and HEAD (or between two refs)

func (*Repo) Exists

func (r *Repo) Exists() bool

Exists checks if the repository exists

func (*Repo) GetCurrentTag

func (r *Repo) GetCurrentTag() (int, error)

GetCurrentTag returns the current tag (based on HEAD)

func (*Repo) GetFilePath

func (r *Repo) GetFilePath() string

GetFilePath returns the full path to the tracked file

func (*Repo) GetLatestTagNumber

func (r *Repo) GetLatestTagNumber() (int, error)

GetLatestTagNumber returns the highest tag number (vN format)

func (*Repo) HasChanges

func (r *Repo) HasChanges() (bool, error)

HasChanges checks if working file differs from HEAD

func (*Repo) Init

func (r *Repo) Init() error

Init initializes a Git repository

func (*Repo) Log

func (r *Repo) Log() ([]Snapshot, error)

Log returns commit history

func (*Repo) Tag

func (r *Repo) Tag(name string) error

Tag creates a tag for the given commit

type Snapshot

type Snapshot struct {
	Number    int
	Message   string
	Timestamp time.Time
	Hash      string
}

Snapshot represents a version snapshot

Jump to

Keyboard shortcuts

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