common

package
v0.0.0-...-f32120d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	NUL   byte = 0x00
	SPACE byte = 0x20
	DELIM byte = 0x0a
)

Variables

View Source
var (
	ErrMalformatedString = errors.New("malformed hexadecimal hash represented string")
)

Functions

func DirOfFilePath

func DirOfFilePath(path string) string

func FileModeToString

func FileModeToString(m FileMode) string

func IsDir

func IsDir(m FileMode) bool

func IsFile

func IsFile(m FileMode) bool

func IsRegular

func IsRegular(m FileMode) bool

func StatTimes

func StatTimes(fi os.FileInfo) (atime, mtime, ctime time.Time)

func ValidateFilePath

func ValidateFilePath(path string) string

Types

type Change

type Change struct {
	From *NameHashPair
	To   *NameHashPair
}

type Changes

type Changes struct {
	Create []*Change
	Remove []*Change
	Modify []*Change
}

func CompareOrderedNameHashPairs

func CompareOrderedNameHashPairs(pairA NameHashPairs, pairB NameHashPairs) *Changes

The tow arguments must be sorted by NameHashPair.Name

type FileInfo

type FileInfo = fs.FileInfo

type FileMode

type FileMode = fs.FileMode
const (
	Empty FileMode = 0

	Dir FileMode = 0040000

	Regular FileMode = 0100644

	Deprecated FileMode = 0100664

	Executable FileMode = 0100755

	Symlink FileMode = 0120000

	Submodule FileMode = 0160000
)

func NewFileMode

func NewFileMode(s string) (FileMode, error)

New takes the octal string representation of a FileMode and returns the FileMode and a nil error. If the string can not be parsed to a 32 bit unsigned octal number, it returns Empty and the parsing error.

Example: "40000" means Dir, "100644" means Regular.

type Hash

type Hash [20]byte

Git Object Id represented with 20 bytes

var InvalidObjectId Hash
var (
	ZeroHash Hash
)

func HashObject

func HashObject(kind string, content []byte) Hash

hash contetn by append gitobject header (kind, size)

func NewHash

func NewHash(s string) (Hash, error)

NewHash return a new Hash from a hexadecimal hash representation "8b80381e99f222fb1ffe69a925f5b10ceace5165" => [ 8b 80 38 1e 99 f2 22 fb 1f fe 69 a9 25 f5 b1 0c ea ce 51 65]

func (Hash) EqualsTo

func (h Hash) EqualsTo(t Hash) bool

func (Hash) String

func (h Hash) String() string

type NameHashPair

type NameHashPair struct {
	Oid  Hash
	Name string
	Mode FileMode
}

type NameHashPairs

type NameHashPairs []*NameHashPair

Jump to

Keyboard shortcuts

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