history

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package history provides a git wrapper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileAtRevision

func FileAtRevision(filepath, hash string) (string, error)

FileAtRevision shows how the file with the given file path looked at the commit with the hash. It may return an error if git fails.

func FileChanged

func FileChanged(path string) bool

FileChanged tells you if the file has been changed.

func HistoryWithRevisions

func HistoryWithRevisions(hyphaName string, revs []Revision) (html string)

HistoryWithRevisions returns an html representation of `revs` that is meant to be inserted in a history page.

func InitGitRepo added in v1.2.0

func InitGitRepo()

func PrimitiveDiffAtRevision

func PrimitiveDiffAtRevision(filepath, hash string) (string, error)

PrimitiveDiffAtRevision generates a plain-text diff for the given filepath at the commit with the given hash. It may return an error if git fails.

func RecentChangesAtom

func RecentChangesAtom() (string, error)

func RecentChangesJSON

func RecentChangesJSON() (string, error)

func RecentChangesRSS

func RecentChangesRSS() (string, error)

func Rename

func Rename(from, to string) error

Rename renames from `from` to `to` using `git mv`.

func Start

func Start()

Start finds git and initializes git credentials.

Types

type HistoryOp

type HistoryOp struct {
	// All errors are appended here.
	Errs []error
	Type OpType
	// contains filtered or unexported fields
}

HistoryOp is an object representing a history operation.

func Operation

func Operation(opType OpType) *HistoryOp

Operation is a constructor of a history operation.

func (*HistoryOp) Abort

func (hop *HistoryOp) Abort() *HistoryOp

Abort aborts the history operation.

func (*HistoryOp) Apply

func (hop *HistoryOp) Apply() *HistoryOp

Apply applies history operation by doing the commit.

func (*HistoryOp) FirstErrorText

func (hop *HistoryOp) FirstErrorText() string

func (*HistoryOp) HasErrors

func (hop *HistoryOp) HasErrors() bool

func (*HistoryOp) WithErr

func (hop *HistoryOp) WithErr(err error) *HistoryOp

WithErr appends the `err` to the list of errors.

func (*HistoryOp) WithErrAbort

func (hop *HistoryOp) WithErrAbort(err error) *HistoryOp

func (*HistoryOp) WithFiles

func (hop *HistoryOp) WithFiles(paths ...string) *HistoryOp

WithFiles stages all passed `paths`. Paths can be rooted or not.

func (*HistoryOp) WithFilesRemoved

func (hop *HistoryOp) WithFilesRemoved(paths ...string) *HistoryOp

WithFilesRemoved git-rm-s all passed `paths`. Paths can be rooted or not. Paths that are empty strings are ignored.

func (*HistoryOp) WithFilesRenamed

func (hop *HistoryOp) WithFilesRenamed(pairs map[string]string) *HistoryOp

WithFilesRenamed git-mv-s all passed keys of `pairs` to values of `pairs`. Paths can be rooted ot not. Empty keys are ignored.

func (*HistoryOp) WithMsg

func (hop *HistoryOp) WithMsg(userMsg string) *HistoryOp

WithMsg sets what message will be used for the future commit. If user message exceeds one line, it is stripped down.

func (*HistoryOp) WithUser

func (hop *HistoryOp) WithUser(u *user.User) *HistoryOp

WithUser sets a user for the commit.

type OpType

type OpType int

OpType is the type a history operation has. Callers shall set appropriate optypes when creating history operations.

const (
	TypeNone OpType = iota
	TypeEditText
	TypeEditBinary
	TypeDeleteHypha
	TypeRenameHypha
	TypeUnattachHypha
)

type Revision

type Revision struct {
	Hash     string
	Username string
	Time     time.Time
	Message  string
	// contains filtered or unexported fields
}

Revision represents a revision, duh. Hash is usually short. Username is extracted from email.

func RecentChanges

func RecentChanges(n int) []Revision

func Revisions

func Revisions(hyphaName string) ([]Revision, error)

Revisions returns slice of revisions for the given hypha name.

func (Revision) HyphaeLinksHTML

func (rev Revision) HyphaeLinksHTML() (html string)

HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by this revision as HTML string.

func (Revision) TimeString

func (rev Revision) TimeString() string

TimeString returns a human readable time representation.

Jump to

Keyboard shortcuts

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