diff --git a/pkg/zeta/worktree_status.go b/pkg/zeta/worktree_status.go index 1579083..5e00be1 100644 --- a/pkg/zeta/worktree_status.go +++ b/pkg/zeta/worktree_status.go @@ -25,6 +25,7 @@ import ( "github.com/antgroup/hugescm/modules/plumbing/filemode" "github.com/antgroup/hugescm/modules/plumbing/format/ignore" "github.com/antgroup/hugescm/modules/plumbing/format/index" + "github.com/antgroup/hugescm/modules/strengthen" "github.com/antgroup/hugescm/modules/vfs" "github.com/antgroup/hugescm/modules/zeta/object" ) @@ -56,8 +57,26 @@ var ( ErrGlobNoMatches = errors.New("glob pattern did not match any files") ) +func (w *Worktree) showFs(verbose bool) { + if !verbose { + return + } + ds, err := strengthen.GetDiskFreeSpaceEx(w.baseDir) + if err != nil { + fmt.Fprintf(os.Stderr, "GetDiskFreeSpaceEx error: %v\n", err) + return + } + gb := float64(1024 * 1024 * 1024) + if warningFs[strings.ToLower(ds.FS)] { + warn("The repository filesystem is '%s', which may affect zeta's operation.", "\x1b[01;33m"+ds.FS+"\x1b[0m") + } + fmt.Fprintf(os.Stderr, "\x1b[33m* Worktree filesystem: \x1b[38;2;0;191;255m%s\x1b[0m \x1b[33mused: \x1b[38;2;255;215;0m%0.2f GB\x1b[0m \x1b[33mavail: \x1b[38;2;63;247;166m%0.2f GB\x1b[0m \x1b[33mtotal: \x1b[38;02;39;199;173m%0.2f GB\x1b[0m \n", + ds.FS, float64(ds.Used)/gb, float64(ds.Avail)/gb, float64(ds.Total)/gb) +} + // Status returns the working tree status. func (w *Worktree) Status(ctx context.Context, verbose bool) (Status, error) { + w.showFs(verbose) // var hash plumbing.Hash ref, err := w.Current()