diff options
author | Bjørn Erik Pedersen <[email protected]> | 2020-12-02 13:23:25 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2020-12-03 13:12:58 +0100 |
commit | d90e37e0c6e812f9913bf256c9c81aa05b7a08aa (patch) | |
tree | 7b1b14464eefec1188ca2eed53c64e4823453cc9 /hugolib/filesystems | |
parent | 32471b57bde51c55a15dbf1db75d6e5f7232c347 (diff) | |
download | hugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.tar.gz hugo-d90e37e0c6e812f9913bf256c9c81aa05b7a08aa.zip |
all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r-- | hugolib/filesystems/basefs.go | 18 | ||||
-rw-r--r-- | hugolib/filesystems/basefs_test.go | 4 |
2 files changed, 2 insertions, 20 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index ae3807360..e977633c8 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -16,6 +16,7 @@ package filesystems import ( + "fmt" "io" "os" "path" @@ -33,8 +34,6 @@ import ( "github.com/gohugoio/hugo/hugofs" - "fmt" - "github.com/gohugoio/hugo/hugolib/paths" "github.com/spf13/afero" ) @@ -80,7 +79,7 @@ func (fs *BaseFs) AllDirs() []hugofs.FileMetaInfo { fs.Content.Dirs, fs.Assets.Dirs, fs.Layouts.Dirs, - //fs.Resources.Dirs, + // fs.Resources.Dirs, fs.StaticDirs, } { dirs = append(dirs, dirSet...) @@ -160,7 +159,6 @@ func (s *SourceFilesystems) FileSystems() []*SourceFilesystem { s.Archetypes, // TODO(bep) static } - } // A SourceFilesystem holds the filesystem for a given source type in Hugo (data, @@ -192,7 +190,6 @@ func (s SourceFilesystems) ContentStaticAssetFs(lang string) afero.Fs { base := afero.NewCopyOnWriteFs(s.Assets.Fs, staticFs) return afero.NewCopyOnWriteFs(base, s.Content.Fs) - } // StaticFs returns the static filesystem for the given language. @@ -277,7 +274,6 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string { // MakePathRelative creates a relative path from the given filename. func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) { - for _, dir := range d.Dirs { meta := dir.(hugofs.FileMetaInfo).Meta() currentPath := meta.Filename() @@ -416,7 +412,6 @@ func (b *sourceFilesystemsBuilder) newSourceFilesystem(name string, fs afero.Fs, } func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) { - if b.theBigFs == nil { theBigFs, err := b.createMainOverlayFs(b.p) @@ -435,7 +430,6 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) { dirs := b.theBigFs.overlayDirs[componentID] return b.newSourceFilesystem(componentID, afero.NewBasePathFs(b.theBigFs.overlayMounts, componentID), dirs) - } b.theBigFs.finalizeDirs() @@ -491,11 +485,9 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) { } return b.result, nil - } func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesystemsCollector, error) { - var staticFsMap map[string]afero.Fs if b.p.Cfg.GetBool("multihost") { staticFsMap = make(map[string]afero.Fs) @@ -536,7 +528,6 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys err := b.createOverlayFs(collector, modsReversed) return collector, err - } func (b *sourceFilesystemsBuilder) isContentMount(mnt modules.Mount) bool { @@ -550,7 +541,6 @@ func (b *sourceFilesystemsBuilder) isStaticMount(mnt modules.Mount) bool { func (b *sourceFilesystemsBuilder) createModFs( collector *filesystemsCollector, md mountsDescriptor) error { - var ( fromTo []hugofs.RootMapping fromToContent []hugofs.RootMapping @@ -641,7 +631,6 @@ func (b *sourceFilesystemsBuilder) createModFs( sfs, found := collector.staticPerLanguage[lang] if found { collector.staticPerLanguage[lang] = afero.NewCopyOnWriteFs(sfs, bfs) - } else { collector.staticPerLanguage[lang] = bfs } @@ -672,7 +661,6 @@ func (b *sourceFilesystemsBuilder) createModFs( } return nil - } func printFs(fs afero.Fs, path string, w io.Writer) { @@ -719,7 +707,6 @@ func (c *filesystemsCollector) addDirs(rfs *hugofs.RootMappingFs) { for _, componentFolder := range files.ComponentFolders { c.addDir(rfs, componentFolder) } - } func (c *filesystemsCollector) addDir(rfs *hugofs.RootMappingFs, componentFolder string) { @@ -737,7 +724,6 @@ func (c *filesystemsCollector) finalizeDirs() { c.reverseFis(dirs) } }) - } func (c *filesystemsCollector) reverseFis(fis []hugofs.FileMetaInfo) { diff --git a/hugolib/filesystems/basefs_test.go b/hugolib/filesystems/basefs_test.go index 2d273ae88..139d0c20e 100644 --- a/hugolib/filesystems/basefs_test.go +++ b/hugolib/filesystems/basefs_test.go @@ -274,7 +274,6 @@ func TestRealDirs(t *testing.T) { c.Assert(realDirs[len(realDirs)-1], qt.Equals, filepath.Join(themesDir, "mytheme/assets/scss")) c.Assert(bfs.theBigFs, qt.Not(qt.IsNil)) - } func TestStaticFs(t *testing.T) { @@ -305,7 +304,6 @@ func TestStaticFs(t *testing.T) { sfs := bfs.StaticFs("en") checkFileContent(sfs, "f1.txt", c, "Hugo Rocks!") checkFileContent(sfs, "f2.txt", c, "Hugo Themes Still Rocks!") - } func TestStaticFsMultiHost(t *testing.T) { @@ -402,7 +400,6 @@ func TestMakePathRelative(t *testing.T) { c.Assert(makeRel(filepath.Join(workDir, "dist", "d1", "foo.txt")), qt.Equals, filepath.FromSlash("mydist/d1/foo.txt")) c.Assert(makeRel(filepath.Join(workDir, "static", "d2", "foo.txt")), qt.Equals, filepath.FromSlash("d2/foo.txt")) c.Assert(makeRel(filepath.Join(workDir, "dust", "d3", "foo.txt")), qt.Equals, filepath.FromSlash("foo/bar/d3/foo.txt")) - } func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) { @@ -412,7 +409,6 @@ func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) { } func checkFileContent(fs afero.Fs, filename string, c *qt.C, expected ...string) { - b, err := afero.ReadFile(fs, filename) c.Assert(err, qt.IsNil) |