history

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: AGPL-3.0 Imports: 20 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 since the last commit.

func InitGitRepo added in v1.2.0

func InitGitRepo()

InitGitRepo checks a Git repository and initializes it if necessary.

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(opts FeedOptions) (string, error)

RecentChangesAtom creates recent changes feed in Atom format.

func RecentChangesJSON

func RecentChangesJSON(opts FeedOptions) (string, error)

RecentChangesJSON creates recent changes feed in JSON format.

func RecentChangesRSS

func RecentChangesRSS(opts FeedOptions) (string, error)

RecentChangesRSS creates recent changes feed in RSS format.

func Rename

func Rename(from, to string) error

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

func SplitPrimitiveDiff added in v1.14.0

func SplitPrimitiveDiff(text string) (result []string)

SplitPrimitiveDiff splits a primitive diff of a single file into hunks.

func Start

func Start()

Start finds git and initializes git credentials.

func StreamWithRevisions added in v1.6.0

func StreamWithRevisions(qw422016 *qt422016.Writer, hyphaName string, revs []Revision)

func WithRevisions added in v1.6.0

func WithRevisions(hyphaName string, revs []Revision) string

func WriteWithRevisions added in v1.6.0

func WriteWithRevisions(qq422016 qtio422016.Writer, hyphaName string, revs []Revision)

Types

type FeedOptions added in v1.6.0

type FeedOptions struct {
	// contains filtered or unexported fields
}

feedGrouping represents a set of conditions that must all be satisfied for revisions to be grouped. If there are no conditions, revisions will never be grouped.

func ParseFeedOptions added in v1.6.0

func ParseFeedOptions(query url.Values) (FeedOptions, error)

type Op added in v1.6.0

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

Op is an object representing a history operation.

func Operation

func Operation(opType OpType) *Op

Operation is a constructor of a history operation.

func (*Op) Abort added in v1.6.0

func (hop *Op) Abort() *Op

Abort aborts the history operation.

func (*Op) Apply added in v1.6.0

func (hop *Op) Apply() *Op

Apply applies history operation by doing the commit. You do not need to call Abort afterwards.

func (*Op) FirstErrorText added in v1.6.0

func (hop *Op) FirstErrorText() string

FirstErrorText extracts first error appended to the operation.

func (*Op) HasErrors added in v1.6.0

func (hop *Op) HasErrors() bool

HasErrors checks whether operation has errors appended.

func (*Op) WithErrAbort added in v1.6.0

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

WithErrAbort appends the `err` to the list of errors and immediately aborts the operation.

func (*Op) WithFiles added in v1.6.0

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

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

func (*Op) WithFilesRemoved added in v1.6.0

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

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

func (*Op) WithFilesRenamed added in v1.6.0

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

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

func (*Op) WithMsg added in v1.6.0

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

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

func (*Op) WithUser added in v1.6.0

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

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 represents an empty operation. Not to be used in practice.
	TypeNone OpType = iota
	// TypeEditText represents an edit of hypha text part.
	TypeEditText
	// TypeEditBinary represents an addition or replacement of hypha media.
	TypeEditBinary
	// TypeDeleteHypha represents a hypha deletion
	TypeDeleteHypha
	// TypeRenameHypha represents a hypha renaming
	TypeRenameHypha
	// TypeRemoveMedia represents media removal
	TypeRemoveMedia
	// TypeMarkupMigration represents a wikimind-powered automatic markup migration procedure
	TypeMarkupMigration
)

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

RecentChanges gathers an arbitrary number of latest changes in form of revisions slice, ordered most recent first.

func Revisions

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

Revisions returns slice of revisions for the given hypha name, ordered most recent first.

func (Revision) HyphaeLinksHTML

func (rev Revision) HyphaeLinksHTML() string

func (Revision) StreamHyphaeLinksHTML added in v1.6.0

func (rev Revision) StreamHyphaeLinksHTML(qw422016 *qt422016.Writer)

func (Revision) TimeString

func (rev Revision) TimeString() string

TimeString returns a human readable time representation.

func (Revision) WriteHyphaeLinksHTML added in v1.6.0

func (rev Revision) WriteHyphaeLinksHTML(qq422016 qtio422016.Writer)

Directories

Path Synopsis
Package histweb provides web stuff for history
Package histweb provides web stuff for history

Jump to

Keyboard shortcuts

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