git

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IgnoredInitOnce  sync.Once
	TopLevelCache    *cached.Map[RepoPath, RepoPath]
	TopLevelInitOnce sync.Once
)

Functions

func DefaultInit

func DefaultInit(repoPath RepoPath) func() *FileGits

func GetBranch

func GetBranch(repoPath RepoPath) string

GetBranch returns the branch of the repository only return the branch when the path is the root of the repository

func GetShortGitStatus

func GetShortGitStatus(repoPath RepoPath) (string, error)

GetShortGitStatus read the git status of the repository located at the path

Types

type Cache

type Cache = *cached.Map[RepoPath, *FileGits]

func GetCache

func GetCache() Cache

type FileGit

type FileGit struct {
	Name string
	X, Y Status
}

FileGit is an entry name with git status the name will not end with file separator

func (*FileGit) Set

func (f *FileGit) Set(XY string)

Set sets the status of the file based on the XY string X Y Meaning -------------------------------------------------

[AMD]   not updated

M [ MTD] updated in index T [ MTD] type changed in index A [ MTD] added to index D deleted from index R [ MTD] renamed in index C [ MTD] copied in index [MTARC] index and work tree matches [ MTARC] M work tree changed since index [ MTARC] T type changed in work tree since index [ MTARC] D deleted in work tree

// R renamed in work tree // C copied in work tree

------------------------------------------------- D D unmerged, both deleted A U unmerged, added by us U D unmerged, deleted by them U A unmerged, added by them D U unmerged, deleted by us A A unmerged, both added U U unmerged, both modified ------------------------------------------------- ? ? untracked ! ! ignored -------------------------------------------------

type FileGits

type FileGits = []FileGit

func ParseShort

func ParseShort(r string) (res FileGits)

ParseShort parses a git status output command It is compatible with the short version of the git status command modified from https://le-gall.bzh/post/go/parsing-git-status-with-go/ author: Sébastien Le Gall

type RepoPath

type RepoPath = string

func GetTopLevel

func GetTopLevel(path string) (RepoPath, error)

GetTopLevel returns the top level of the repoPath the returned path is cleaned by pathbeautify.CleanSeparator

type RepoStatus

type RepoStatus uint8
const (
	RepoStatusSkip RepoStatus = iota
	RepoStatusClean
	RepoStatusDirty
)

func GetRepoStatus

func GetRepoStatus(repoPath RepoPath) RepoStatus

GetRepoStatus returns the status of the repository only return the status when the path is the root of the repository

func (RepoStatus) String

func (r RepoStatus) String() string

type Status

type Status uint8
const (
	Unknown           Status = iota
	Unmodified               // -
	Modified                 // M
	Added                    // A
	Deleted                  // D
	Renamed                  // R
	Copied                   // C
	Untracked                // ?
	Ignored                  // !
	TypeChanged              // T
	UpdatedBuUnmerged        // U
)

func Byte2Status

func Byte2Status(c byte) Status

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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