fix pre delete dirmd set dir bug and implement last git sha and commit#
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user