Skip to content

Commit

Permalink
status: zeta status -V show diskFreeSpace and fs type info
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Nov 23, 2024
1 parent 6758fb7 commit 95e0d17
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/zeta/worktree_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 95e0d17

Please sign in to comment.