Skip to content

Commit f4d14d2

Browse files
committed
close #82 update plow for concourse
1 parent 402da25 commit f4d14d2

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

ci/notes/CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
We have changed to agent upnext command so automation becomes easier, this is a quickfix and non critical
2-
for users who uses do not use the agent commandset.
1+
We have enhanced the phlow so it's better to use it when building pipelines supporting pretested integration
32

43

5-
#### Patch
6-
- upnext returns a name ready for checkout #79 @groenborg
4+
5+
#### Features
6+
- upnext now has a prefix option #79 @groenborg
77

cmd/upnext.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var upNextCmd = &cobra.Command{
1919
Long: fmt.Sprintf(`
2020
%s gets the next branch ready for integration based on the branch creation time.
2121
The branch created first, is the branch thats up next.
22+
if no --prefix flag is set, the default prefix is ready/
2223
`, ui.Format.Bold("upnext")),
2324
PreRun: func(cmd *cobra.Command, args []string) {
2425
cmdperm.RequiredCurDirRepository()
@@ -28,7 +29,7 @@ The branch created first, is the branch thats up next.
2829
defaultBranch, _ := plugins.GitHub.Branch.Default()
2930
remote := githandler.ConfigBranchRemote(defaultBranch)
3031

31-
phlow.UpNext(remote)
32+
phlow.UpNext(remote, options.GlobalFlagPrefixForReady)
3233
},
3334
}
3435

@@ -38,4 +39,5 @@ func init() {
3839

3940
upNextCmd.Flags().BoolVar(&options.GlobalFlagHumanReadable, "human", false, "output human readable info")
4041

42+
upNextCmd.Flags().StringVarP(&options.GlobalFlagPrefixForReady, "prefix", "p", "", "prefix branches ready for integration")
4143
}

githandler/branch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ func BranchDelivered(remote string) (localBranches []string, remoteBranches []st
7878
}
7979

8080
//BranchReady ...
81-
func BranchReady(remote string) (remoteBranches []string) {
81+
func BranchReady(remote string, prefix string) (remoteBranches []string) {
8282
info, err := Branch()
8383
if err != nil {
8484
return
8585
}
8686

8787
for _, branch := range info.List {
88-
if strings.HasPrefix(branch, "remotes/"+remote+"/ready") {
88+
if strings.HasPrefix(branch, "remotes/"+remote+"/"+prefix) {
8989
branch = strings.TrimPrefix(branch, "remotes/")
9090
remoteBranches = append(remoteBranches, branch)
9191
}

options/option.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ var (
2626
//GlobalFlagHumanReadable ...
2727
GlobalFlagHumanReadable bool
2828

29+
//GlobalFlagPrefixForReady ...
30+
GlobalFlagPrefixForReady string
31+
2932
//GlobalFlagHard ...
3033
GlobalFlagHard bool
3134

phlow/upnext.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ import (
1313
//UpNext ...
1414
//Returns the next branch ready for integration based on time of creation
1515
//Oldest branches gets integrated first.
16-
func UpNext(remote string) {
16+
func UpNext(remote string, prefix string) {
1717

18-
branches := githandler.BranchReady(remote)
18+
if prefix == "" {
19+
prefix = "ready/"
20+
}
21+
22+
branches := githandler.BranchReady(remote, prefix)
1923

2024
if len(branches) != 0 {
2125
if options.GlobalFlagHumanReadable {

0 commit comments

Comments
 (0)