Detect buildpacks for specific branch (fall back to deploy-branch to be consistent with deployment behavior)

This commit is contained in:
Tasos Maschalidis
2025-10-16 18:33:47 +03:00
parent e234401178
commit 65e0fb9037
4 changed files with 20 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ Additional commands:`
helpContent = `
buildpacks:add [--index 1] <app> <buildpack>, Add new app buildpack while inserting into list of buildpacks if necessary
buildpacks:clear <app>, Clear all buildpacks set on the app
buildpacks:detect <app>, Detect the buildpack for an app
buildpacks:detect <app> [--branch <branch-name>], Detect the buildpack for an app (if not specified, the branch flag defaults to the deploy branch)
buildpacks:list <app>, List all buildpacks for an app
buildpacks:remove <app> <buildpack>, Remove a buildpack set on the app
buildpacks:report [<app>] [<flag>], Displays a buildpack report for one or more apps

View File

@@ -32,9 +32,13 @@ func main() {
err = buildpacks.CommandClear(appName)
case "detect":
args := flag.NewFlagSet("buildpacks:detect", flag.ExitOnError)
branch := args.String("branch", "", "--branch: the branch to detect against (defaults to the deploy branch)")
args.Parse(os.Args[2:])
appName := args.Arg(0)
err = buildpacks.CommandDetect(appName)
if *branch == "" {
*branch = common.PropertyGet("git", appName, "deploy-branch")
}
err = buildpacks.CommandDetect(appName, *branch)
case "list":
args := flag.NewFlagSet("buildpacks:list", flag.ExitOnError)
args.Parse(os.Args[2:])