Documentation
¶
Overview ¶
Package history provides a git wrapper.
Index ¶
- func FileAtRevision(filepath, hash string) (string, error)
- func FileChanged(path string) bool
- func InitGitRepo()
- func PrimitiveDiffAtRevision(filepath, hash string) (string, error)
- func RecentChangesAtom(opts FeedOptions) (string, error)
- func RecentChangesJSON(opts FeedOptions) (string, error)
- func RecentChangesRSS(opts FeedOptions) (string, error)
- func Rename(from, to string) error
- func SplitPrimitiveDiff(text string) (result []string)
- func Start() error
- func WithRevisions(hyphaName string, revs []Revision) string
- type FeedOptions
- type Op
- func (hop *Op) Abort() *Op
- func (hop *Op) Apply() *Op
- func (hop *Op) FirstErrorText() string
- func (hop *Op) HasErrors() bool
- func (hop *Op) WithErrAbort(err error) *Op
- func (hop *Op) WithFiles(paths ...string) *Op
- func (hop *Op) WithFilesRemoved(paths ...string) *Op
- func (hop *Op) WithFilesRenamed(pairs map[string]string) *Op
- func (hop *Op) WithMsg(userMsg string) *Op
- func (hop *Op) WithUser(u *usersvc.User) *Op
- type OpType
- type Revision
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileAtRevision ¶
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 ¶
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 ¶
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 SplitPrimitiveDiff ¶ added in v1.14.0
SplitPrimitiveDiff splits a primitive diff of a single file into hunks.
func WithRevisions ¶ added in v1.6.0
WithRevisions returns an HTML representation of `revs` that is meant to be inserted in a history page.
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 (*Op) Apply ¶ added in v1.6.0
Apply applies history operation by doing the commit. You do not need to call Abort afterwards.
func (*Op) FirstErrorText ¶ added in v1.6.0
FirstErrorText extracts first error appended to the operation.
func (*Op) WithErrAbort ¶ added in v1.6.0
WithErrAbort appends the `err` to the list of errors and immediately aborts the operation.
func (*Op) WithFiles ¶ added in v1.6.0
WithFiles stages all passed `paths`. Paths can be rooted or not.
func (*Op) WithFilesRemoved ¶ added in v1.6.0
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
WithFilesRenamed git-mv-s all passed keys of `pairs` to values of `pairs`. Paths can be rooted ot not. Empty keys are ignored.
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 is usually short.
Hash string
// Username is extracted from email.
Username string
Time time.Time
Message string
// contains filtered or unexported fields
}
Revision represents a revision of a hypha.
func RecentChanges ¶
RecentChanges gathers an arbitrary number of latest changes in form of revisions slice, ordered most recent first.
func Revisions ¶
Revisions returns slice of revisions for the given hypha name, ordered most recent first.
func (Revision) HyphaeDiffsHTML ¶ added in v1.15.0
HyphaeDiffsHTML returns a comma-separated list of diffs links of current revision for every affected file as HTML string.
func (Revision) HyphaeLinksHTML ¶
HyphaeLinksHTML returns a comma-separated list of hyphae that were affected by this revision as HTML string.
func (Revision) TimeString ¶
TimeString returns a human readable time representation.