fix pre delete dirmd set dir bug and implement last git sha and commit#

This commit is contained in:
2026-09-02 11:43:45 +01:00
parent 89b7eb78a7
commit 93d830d500
5 changed files with 72 additions and 14 deletions
+9
View File
@@ -9,6 +9,7 @@ import (
"git.flo.fo/FLO/dirmd/internal/config"
"git.flo.fo/FLO/dirmd/internal/filter"
"git.flo.fo/FLO/dirmd/internal/git"
)
type Entry struct {
@@ -21,6 +22,7 @@ type Result struct {
AbsRoot string
SingleFile bool
OmitTest bool
Commit *git.CommitInfo
}
func Run(cfg *config.Config) (*Result, error) {
@@ -53,11 +55,15 @@ func processSingleFile(cfg *config.Config) (*Result, error) {
return nil, fmt.Errorf("file %s filtered out", cfg.AbsRoot)
}
// For single files, try to get git info from the parent directory
commitInfo := git.GetCommitInfo(filepath.Dir(cfg.AbsRoot))
return &Result{
Entries: []Entry{{RelPath: filepath.Base(cfg.AbsRoot), Size: info.Size()}},
AbsRoot: filepath.Dir(cfg.AbsRoot),
SingleFile: true,
OmitTest: cfg.OmitTest,
Commit: commitInfo,
}, nil
}
@@ -73,6 +79,9 @@ func walkDirectory(cfg *config.Config) (*Result, error) {
result := &Result{AbsRoot: cfg.AbsRoot, OmitTest: cfg.OmitTest}
// Fetch git info for the root directory
result.Commit = git.GetCommitInfo(cfg.AbsRoot)
err := filepath.WalkDir(cfg.AbsRoot, func(path string, d fs.DirEntry, err error) error {
if err != nil {
fmt.Fprintf(os.Stderr, "warning: %v\n", err)