Skip to content

Commit

Permalink
Leave VCS files when using clean after
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Sep 27, 2018
1 parent 9ac4ab6 commit bf0ab32
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
36 changes: 34 additions & 2 deletions clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,45 @@ func cleanUntracked() error {
}

dir := filepath.Join(config.BuildDir, file.Name())

if shouldUseGit(dir) {
if err = show(passToGit(dir, "clean", "-fx")); err != nil {
if err := show(passToGit(dir, "clean", "-fx")); err != nil {
return err
}
}
}

return nil
}

func cleanAfter(bases []Base) {
fmt.Println("removing Untracked AUR files from cache...")

for i, base := range bases {
dir := filepath.Join(config.BuildDir, base.Pkgbase())

if shouldUseGit(dir) {
fmt.Printf(bold(cyan("::")+" Cleaning (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
_, stderr, err := capture(passToGit(dir, "reset", "--hard", "HEAD"))
if err != nil {
fmt.Printf("error resetting %s: %s", base.String(), stderr)
}

show(passToGit(dir, "clean", "-fx"))
} else {
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
if err := os.RemoveAll(dir); err != nil {
fmt.Println(err)
}
}
}
}

func cleanBuilds(bases []Base) {
for i, base := range bases {
dir := filepath.Join(config.BuildDir, base.Pkgbase())
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
if err := os.RemoveAll(dir); err != nil {
fmt.Println(err)
}
}
}
10 changes: 1 addition & 9 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func install(parser *arguments) error {
}

if config.CleanAfter {
cleanBuilds(do.Aur)
cleanAfter(do.Aur)
}

return nil
Expand Down Expand Up @@ -680,14 +680,6 @@ func editDiffNumberMenu(bases []Base, installed stringSet, diff bool) ([]Base, e
return toEdit, nil
}

func cleanBuilds(bases []Base) {
for i, base := range bases {
dir := filepath.Join(config.BuildDir, base.Pkgbase())
fmt.Printf(bold(cyan("::")+" Deleting (%d/%d): %s\n"), i+1, len(bases), cyan(dir))
os.RemoveAll(dir)
}
}

func showPkgbuildDiffs(bases []Base, cloned stringSet) error {
for _, base := range bases {
pkg := base.Pkgbase()
Expand Down

0 comments on commit bf0ab32

Please sign in to comment.