MCPcopy
hub / github.com/Jguer/yay / cleanAfter

Function cleanAfter

pkg/sync/workdir/clean.go:38–62  ·  view source on GitHub ↗
(ctx context.Context, run *runtime.Runtime,
	cmdBuilder exe.ICmdBuilder, pkgbuildDirs map[string]string,
)

Source from the content-addressed store, hash-verified

36}
37
38func cleanAfter(ctx context.Context, run *runtime.Runtime,
39 cmdBuilder exe.ICmdBuilder, pkgbuildDirs map[string]string,
40) {
41 run.Logger.Println(gotext.Get("removing untracked AUR files from cache..."))
42
43 i := 0
44 for _, dir := range pkgbuildDirs {
45 run.Logger.OperationInfoln(gotext.Get("Cleaning (%d/%d): %s", i+1, len(pkgbuildDirs), text.Cyan(dir)))
46
47 _, stderr, err := cmdBuilder.Capture(
48 cmdBuilder.BuildGitCmd(
49 ctx, dir, "reset", "--hard", "HEAD"))
50 if err != nil {
51 run.Logger.Errorln(gotext.Get("error resetting %s: %s", dir, stderr))
52 }
53
54 if err := run.CmdBuilder.Show(
55 run.CmdBuilder.BuildGitCmd(
56 ctx, dir, "clean", "-fx", "--exclude", "*.pkg.*")); err != nil {
57 run.Logger.Errorln(err)
58 }
59
60 i++
61 }
62}

Callers 2

TestCleanAfterFunction · 0.85
ShouldCleanAURDirsMethod · 0.85

Calls 8

CyanFunction · 0.92
PrintlnMethod · 0.80
OperationInfolnMethod · 0.80
ErrorlnMethod · 0.80
GetMethod · 0.65
CaptureMethod · 0.65
BuildGitCmdMethod · 0.65
ShowMethod · 0.65

Tested by 1

TestCleanAfterFunction · 0.68