Remove redundant function isBareGitRepo

This commit is contained in:
Tasos Maschalidis
2025-10-16 17:17:29 +03:00
parent 4b0c8b3d59
commit 66894bc0c5
2 changed files with 10 additions and 21 deletions

View File

@@ -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 {

View File

@@ -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",