mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Misc doc, code refactoring to improve documentation
This commit is contained in:
@@ -18,7 +18,9 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bep/gitmap"
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
@@ -294,3 +296,31 @@ func (sp *SourceSpec) NewFileInfo(fi hugofs.FileMetaInfo) (*FileInfo, error) {
|
||||
|
||||
return f, nil
|
||||
}
|
||||
|
||||
func NewGitInfo(info gitmap.GitInfo) GitInfo {
|
||||
return GitInfo(info)
|
||||
}
|
||||
|
||||
// GitInfo provides information about a version controled source file.
|
||||
type GitInfo struct {
|
||||
// Commit hash.
|
||||
Hash string `json:"hash"`
|
||||
// Abbreviated commit hash.
|
||||
AbbreviatedHash string `json:"abbreviatedHash"`
|
||||
// The commit message's subject/title line.
|
||||
Subject string `json:"subject"`
|
||||
// The author name, respecting .mailmap.
|
||||
AuthorName string `json:"authorName"`
|
||||
// The author email address, respecting .mailmap.
|
||||
AuthorEmail string `json:"authorEmail"`
|
||||
// The author date.
|
||||
AuthorDate time.Time `json:"authorDate"`
|
||||
// The commit date.
|
||||
CommitDate time.Time `json:"commitDate"`
|
||||
}
|
||||
|
||||
// IsZero returns true if the GitInfo is empty,
|
||||
// meaning it will also be falsy in the Go templates.
|
||||
func (g GitInfo) IsZero() bool {
|
||||
return g.Hash == ""
|
||||
}
|
||||
|
Reference in New Issue
Block a user