From 4b0c8b3d59a4eab41e977fb2b37ba3c61ed6c26d Mon Sep 17 00:00:00 2001 From: Tasos Maschalidis Date: Wed, 1 Oct 2025 00:46:05 +0300 Subject: [PATCH] Refactor CommandDetect function --- plugins/buildpacks/subcommands.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index 4674eb4e8..624a42bb1 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -37,30 +37,23 @@ func CommandDetect(appName string) error { return err } - buildPath := common.AppRoot(appName) - if !common.DirectoryExists(buildPath) { - return fmt.Errorf("App %s does not exist", appName) - } - - workDir := buildPath - if isBareGitRepo(buildPath) { - checkedOutPath, err := checkoutBareGitRepo(buildPath) + workDir := common.AppRoot(appName) + if isBareGitRepo(workDir) { + checkedOutDir, err := checkoutBareGitRepo(workDir) if err != nil { return err } - workDir = checkedOutPath + workDir = checkedOutDir defer func() { - if err := os.RemoveAll(checkedOutPath); err != nil { - common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutPath, err)) + if err := os.RemoveAll(checkedOutDir); err != nil { + common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutDir, err)) } }() } - appRoot := workDir - dockerArgs := []string{ "run", "--rm", - "-v", fmt.Sprintf("%s:/tmp/app", appRoot), + "-v", fmt.Sprintf("%s:/tmp/app", workDir), "gliderlabs/herokuish", "/bin/herokuish", "buildpack", "detect", "/tmp/app", }