Documentation ¶
Overview ¶
Package data implements data types that are passed to the various templates.
Index ¶
- Variables
- type Blob
- type BlobData
- type BlobLine
- type Chunk
- type Commit
- type CommitData
- type DiffData
- type FileMode
- type FilePatch
- type Hash
- type IndexData
- type LogData
- type Operation
- type PatchInfo
- type PathElem
- type Reference
- type RefsData
- type Repo
- type RequestData
- type Tree
- type TreeData
- type TreeEntry
Constants ¶
This section is empty.
Variables ¶
var ( // LogPageSize is the number of log entries presented per // page. LogPageSize = 20 // DiffContext is t he number of context lines presented on // either side of a diff DiffContext = 3 )
Functions ¶
This section is empty.
Types ¶
type Blob ¶
type Blob struct { // The blob hash Hash string // The size of the blob Size int64 // The contents of the blob Lines []BlobLine }
Blob is information related to a Git blob.
type BlobData ¶
type BlobData struct { RequestData // Commit information related to the blob. Commit Commit // The Blob itself. Blob Blob }
BlobData extends RequestData and is provided to the blob template when executed and becomes dot within the template.
The data in TreeData is, properly speaking, a conglomeration of both commit and tree data. The data is combined here for ease of presentation.
type Commit ¶
type Commit struct { // Hash of the commit object. Hash Hash // Author is the original author of the commit. Author string // Committer is the one performing the commit, might be different from // Author. Committer string // Message is the commit message, contains arbitrary text. Message string // ParentHashes are the hash(es) of the parent commit(s) ParentHashes []Hash // Time is the commit timestamp Time time.Time }
Commit contains information related to a Git commit.
func (Commit) HasParents ¶
HasParents returns true when c has one or more parents. Otherwise it returns false.
type CommitData ¶
type CommitData struct { // The repository Repo Repo // The revision Revision string // The commit Commit Commit // The commit diffstat, populated from [object.FileStats.String]. Diffstat string // A slice of file patches FilePatches []FilePatch }
CommitData is provided to the commit template when executed and becomes dot within the template.
type DiffData ¶
type DiffData struct { // The repository Repo Repo // The source (from) and destination (to) revision From, To string // The diffstat Diffstat string // File patches FilePatches []FilePatch }
DiffData is provided to the diff template when executed and becomes dot within the template.
type FileMode ¶
type FileMode uint8
FileMode contains the encoded type of a Git tree entry.
type FilePatch ¶
type FilePatch struct { // True if the file is binary, otherwise false. IsBinary bool // The file name File string // A slice of chunks representing changes to the file Chunks []Chunk }
FilePatch represents the changes to an individual file.
func (FilePatch) Info ¶
Info converts fp to a slice of PatchInfo, ideal for display within an HTML table.
func (FilePatch) String ¶
String implements the fmt.Stringer interface for FilePatch.
type IndexData ¶
type IndexData struct { // Repos is a slice of repositories Repos []*Repo }
IndexData is provided to the index template when executed and becomes dot within the template.
type LogData ¶
type LogData struct { // The repository Repo Repo // The revision Revision string // The hash from which to begin displaying the log FromHash Hash // A slice of Git commit information Commits []Commit // The hash of the first commit for the next page NextPage Hash }
LogData is provided to the log template when executed and becomes dot within the template.
type PatchInfo ¶
type PatchInfo struct {
// The line numbers in the left (old) and right (new) files
Left, Right string
// The operation being performed in the current line
Operation Operation
// The content of the current line
Content string
}
PatchInfo represents a single line of a file patch, structured for display within an HTML table.
type PathElem ¶
type PathElem struct { // Repo is the repository slug. Repo string // Revision is the Git revision. Revision string // Path is the path within the repository, excluding the // current path element and any following it. Path string // Base is the current path element. Base string }
The PathElem struct contains information for a repository path element.
type Reference ¶
type Reference struct { // The name of the reference Name string // The time the reference was created or last updated // (whichever is most recent) Time time.Time }
Reference contains information pertaining to a Git repository reference.
type RefsData ¶
type RefsData struct { // The repository Repo Repo // A slice containing all branch references Branches []Reference // A slice containing all tag references Tags []Reference }
RefsData is provided to the refs template when executed and becomes dot within the template.
type Repo ¶
type Repo struct { // Slug is the URL path to the repository, relative to the // DGit root URL. Slug string // Owner is the repository owner as read from the gitweb.owner // Git config key. Owner string // Description is the repository description as read from the // gitweb.description Git config key. Description string // LastModified records the timestamp of the most recent // commit as read from info/web/last-modified within the // repository's Git directory. LastModified time.Time }
The Repo struct contains data for a single repository.
type RequestData ¶
type RequestData struct { // The repository Repo Repo // The base name of the Git reference, or the commit hash. Revision string // The path of the tree within the repository. Path string }
RequestData is the base type for several of the other data types.
func (RequestData) PathBase ¶
func (r RequestData) PathBase() string
PathBase returns the base name of the request path. Returned data has the property requestData.RequestBase() = path.Base(requestData.Path).
func (RequestData) PathElems ¶
func (r RequestData) PathElems() []PathElem
PathElems returns a slice of PathElem objects for each directory in [RequestData.Path]. This is useful to build a breadcrumb, which might look like:
{{ for range .PathElems -}} <a href="/{{ .Repo }}/-/tree/{{ .Revision }}{{ .Path }}">{{ .Base }}</a> {{- end }}
type Tree ¶
type Tree struct { // Entries describes the entries in the current tree. Entries []TreeEntry // Hash is the hash of the current tree. Hash Hash }
Tree contains information related to a Git tree.
type TreeData ¶
type TreeData struct { RequestData // Commit information related to the tree. Commit Commit // The Tree itself. Tree Tree // Tree README contents. Readme string }
TreeData extends RequestData and is provided to the head and tree templates when executed and becomes dot within the template.
The data in TreeData is, properly speaking, a conglomeration of both commit and tree data. The data is combined here for ease of presentation.
type TreeEntry ¶
type TreeEntry struct { // The file name. Name string // The file mode. See [FileMode]. Mode FileMode // The file hash. Hash Hash // The link (href) to view the file. Href string }
TreeEntry contains information related to a tree entry. For purposes of a TreeEntry, "file" should be understood to mean blob or tree.