git

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 7 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 FreeCache

func FreeCache()

func GetShortGitStatus

func GetShortGitStatus(repoPath RepoPath) (string, error)

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

Types

type Cache added in v0.9.0

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 added in v0.10.0

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 added in v0.9.0

type RepoPath = string

func GetTopLevel added in v0.9.0

func GetTopLevel(path string) (RepoPath, error)

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

type Status

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

func Byte2Status added in v0.10.0

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