Refactor CommandDetect function
This commit is contained in:
@@ -37,30 +37,23 @@ func CommandDetect(appName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
buildPath := common.AppRoot(appName)
|
workDir := common.AppRoot(appName)
|
||||||
if !common.DirectoryExists(buildPath) {
|
if isBareGitRepo(workDir) {
|
||||||
return fmt.Errorf("App %s does not exist", appName)
|
checkedOutDir, err := checkoutBareGitRepo(workDir)
|
||||||
}
|
|
||||||
|
|
||||||
workDir := buildPath
|
|
||||||
if isBareGitRepo(buildPath) {
|
|
||||||
checkedOutPath, err := checkoutBareGitRepo(buildPath)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
workDir = checkedOutPath
|
workDir = checkedOutDir
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := os.RemoveAll(checkedOutPath); err != nil {
|
if err := os.RemoveAll(checkedOutDir); err != nil {
|
||||||
common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutPath, err))
|
common.LogWarn(fmt.Sprintf("Failed to remove temporary directory %s: %v", checkedOutDir, err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
appRoot := workDir
|
|
||||||
|
|
||||||
dockerArgs := []string{
|
dockerArgs := []string{
|
||||||
"run", "--rm",
|
"run", "--rm",
|
||||||
"-v", fmt.Sprintf("%s:/tmp/app", appRoot),
|
"-v", fmt.Sprintf("%s:/tmp/app", workDir),
|
||||||
"gliderlabs/herokuish", "/bin/herokuish", "buildpack", "detect", "/tmp/app",
|
"gliderlabs/herokuish", "/bin/herokuish", "buildpack", "detect", "/tmp/app",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user