From 66894bc0c5fd7d5b3b2dedc71a03002d01aaf343 Mon Sep 17 00:00:00 2001 From: Tasos Maschalidis Date: Thu, 16 Oct 2025 17:17:29 +0300 Subject: [PATCH] Remove redundant function isBareGitRepo --- plugins/buildpacks/functions.go | 9 --------- plugins/buildpacks/subcommands.go | 22 ++++++++++------------ 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/plugins/buildpacks/functions.go b/plugins/buildpacks/functions.go index 0252e239e..1845efae8 100644 --- a/plugins/buildpacks/functions.go +++ b/plugins/buildpacks/functions.go @@ -64,15 +64,6 @@ func validBuildpackURL(buildpack string) (string, error) { return buildpack, fmt.Errorf("Invalid buildpack specified: %v", buildpack) } -func isBareGitRepo(directory string) bool { - headFile := filepath.Join(directory, "HEAD") - objectsDir := filepath.Join(directory, "objects") - if common.FileExists(headFile) && common.DirectoryExists(objectsDir) { - return true - } - return false -} - func checkoutBareGitRepo(sourceWorkDir string) (string, error) { tmpdir, err := os.MkdirTemp("", "bare-git-checkout") if err != nil { diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index 624a42bb1..64578012d 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -38,18 +38,16 @@ func CommandDetect(appName string) error { } workDir := common.AppRoot(appName) - if isBareGitRepo(workDir) { - checkedOutDir, err := checkoutBareGitRepo(workDir) - if err != nil { - return err - } - workDir = checkedOutDir - defer func() { - if err := os.RemoveAll(checkedOutDir); err != nil { - common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutDir, err)) - } - }() - } + checkedOutDir, err := checkoutBareGitRepo(workDir) + if err != nil { + return err + } + workDir = checkedOutDir + defer func() { + if err := os.RemoveAll(checkedOutDir); err != nil { + common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutDir, err)) + } + }() dockerArgs := []string{ "run", "--rm",