mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Add Page.GitInfo support for content from Git modules
Use blobless git clone (--filter=blob:none --no-checkout) to fetch commit history for content from Git modules, then map it using the existing gitmap library. Cloned repos are cached in the modulegitinfo file cache. Closes #14431 Fixes #5533
This commit is contained in:
committed by
GitHub
parent
2d691c7e47
commit
dfece5b674
@@ -79,6 +79,17 @@ type Module interface {
|
||||
|
||||
// Whether this module's dir is a watch candidate.
|
||||
Watch() bool
|
||||
|
||||
// Origin returns the module's origin info if available (VCS, URL, Hash, etc.).
|
||||
Origin() ModuleOrigin
|
||||
}
|
||||
|
||||
// ModuleOrigin contains origin info for a Go module.
|
||||
type ModuleOrigin struct {
|
||||
VCS string // version control system, e.g. "git"
|
||||
URL string // repository URL, e.g. "https://github.com/bep/hugo-testing-git-versions"
|
||||
Hash string // commit hash
|
||||
Ref string // e.g. "refs/tags/v3.0.1"
|
||||
}
|
||||
|
||||
type Modules []Module
|
||||
@@ -219,3 +230,15 @@ func (m *moduleAdapter) Watch() bool {
|
||||
// That leaves modules inside the read-only module cache.
|
||||
return !m.gomod.Indirect
|
||||
}
|
||||
|
||||
func (m *moduleAdapter) Origin() ModuleOrigin {
|
||||
if !m.IsGoMod() || m.gomod.Origin == nil {
|
||||
return ModuleOrigin{}
|
||||
}
|
||||
return ModuleOrigin{
|
||||
VCS: m.gomod.Origin.VCS,
|
||||
URL: m.gomod.Origin.URL,
|
||||
Hash: m.gomod.Origin.Hash,
|
||||
Ref: m.gomod.Origin.Ref,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user