gogit

package module
v0.0.0-...-7baddd9 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 9 Imported by: 0

README

gogit

Playing with git in pure go... Because why not?

See here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHeader

func NewHeader(contentType ContentType, length int) ([]byte, error)

func TimeSecsOffset

func TimeSecsOffset(t time.Time) (secs int, offset string)

Types

type Commit

type Commit struct {
	Tree          Sha1
	Parents       []Sha1
	Author        commitUser
	Committor     commitUser
	CommitMessage string
}

func (*Commit) Content

func (c *Commit) Content() ([]byte, error)

func (*Commit) SetAuthor

func (c *Commit) SetAuthor(name string, email string, timesecs int, offset string)

func (*Commit) SetCommittor

func (c *Commit) SetCommittor(name string, email string, timesecs int, offset string)

func (*Commit) WriteContent

func (c *Commit) WriteContent(w io.Writer) (err error)

type ContentType

type ContentType string
const (
	ContentType_Blob   ContentType = "blob"
	ContentType_Commit ContentType = "commit"
	ContentType_Tree   ContentType = "tree"
)

type Mode

type Mode int32

Mode

const (
	Mode_RegularFile Mode = 100644 // 100644
	Mode_Tree        Mode = 40000  // 40000
)

func (Mode) String

func (i Mode) String() string

type Object

type Object struct {
	// header, "blob length-of-content" and terminating null byte.
	Header []byte
	// digest is the 20 byte sha-1 hash of header + content
	Digest Sha1
	// Blob contains the actually zlib-compressed header + content of the blob.
	Blob []byte
}

func NewObject

func NewObject(
	contentType ContentType,
	content []byte,
) (*Object, error)

func (*Object) HexDigest

func (o *Object) HexDigest() string

type Sha1

type Sha1 [sha1Length]byte

func (*Sha1) Equals

func (s *Sha1) Equals(e *Sha1) bool

func (Sha1) MarshalText

func (s Sha1) MarshalText() (text []byte, err error)

func (*Sha1) String

func (s *Sha1) String() string

func (*Sha1) UnmarshalString

func (s *Sha1) UnmarshalString(src string) error

func (*Sha1) UnmarshalText

func (s *Sha1) UnmarshalText(text []byte) error

type Tree

type Tree struct {
	Entries []*TreeEntry
}

func (*Tree) Add

func (tree *Tree) Add(mode Mode, name string, sha1 Sha1) error

Add adds an entry to the tree, error if it's a duplicate

func (*Tree) AddOrReplace

func (tree *Tree) AddOrReplace(mode Mode, name string, sha1 Sha1) error

AddOrReplace will replace an entry if the name already exists, or add it to tree if the name doesn't exist.

func (*Tree) Content

func (tree *Tree) Content() ([]byte, error)

Content generates the byte array (uncompressed for tree)

func (*Tree) Replace

func (tree *Tree) Replace(mode Mode, name string, sha1 Sha1) error

Replace an entry in the tree by its name, error if not found.

func (*Tree) WriteContent

func (tree *Tree) WriteContent(w io.Writer) error

WriteContent writes the content of the tree to the given io.Writer.

type TreeEntry

type TreeEntry struct {
	Mode int32  `json:"mode,omitempty"`
	Name string `json:"name,omitempty"`
	Sha1 Sha1   `json:"sha1,omitempty"`
}

func NewTreeEntry

func NewTreeEntry(mode Mode, name string, sha1 Sha1) *TreeEntry

NewTreeEntry creates a new TreeEntry.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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