add timestamp to dirmd files
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.flo.fo/FLO/dirmd/internal/tree"
|
||||
@@ -35,7 +36,12 @@ func Write(result *walker.Result, outputPath string, appendMode bool, singleFile
|
||||
h1Path = filepath.Join(result.AbsRoot, result.Entries[0].RelPath)
|
||||
}
|
||||
|
||||
fmt.Fprintf(&sb, "# %s [ROOT]\n\n", h1Path)
|
||||
fmt.Fprintf(&sb, "# %s [ROOT]\n", h1Path)
|
||||
|
||||
// Add timestamp only if creating a new file (not append mode)
|
||||
if !appendMode {
|
||||
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||
}
|
||||
|
||||
if !singleFile {
|
||||
root := tree.Build(result.Entries)
|
||||
@@ -162,7 +168,9 @@ func writeRootSlice(path, absRoot, rootName, repoName string, rootFiles []walker
|
||||
|
||||
var sb strings.Builder
|
||||
|
||||
fmt.Fprintf(&sb, "# %s [ROOT]\n\n", absRoot)
|
||||
fmt.Fprintf(&sb, "# %s [ROOT]\n", absRoot)
|
||||
// Timestamp for new file creation
|
||||
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||
|
||||
treeLines := buildTreeWithRefs(rootName, repoName, topLevelDirs, rootFiles)
|
||||
sb.WriteString("## Directory Tree\n\n")
|
||||
@@ -239,7 +247,9 @@ func writeDirSlice(path, absDir, absRoot, dirName string, treeEntries, fileEntri
|
||||
|
||||
var sb strings.Builder
|
||||
|
||||
fmt.Fprintf(&sb, "# %s [SLICE]\n\n", absDir)
|
||||
fmt.Fprintf(&sb, "# %s [SLICE]\n", absDir)
|
||||
// Timestamp for new file creation
|
||||
fmt.Fprintf(&sb, "> Generated: %s\n\n", time.Now().Format(time.RFC3339))
|
||||
fmt.Fprintf(&sb, "Root document: %s\n\n", rootFileName)
|
||||
|
||||
sb.WriteString("## Directory Tree\n\n")
|
||||
|
||||
Reference in New Issue
Block a user