Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit a8d4ac4

Browse files
authored
Merge pull request #18 from hellofresh/patch/add-branch-option
Add branch argument when seating a candidate
2 parents a0b0e0d + d3ce623 commit a8d4ac4

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cmd/hiring_send.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/hellofresh/github-cli/pkg/repo"
1515
"github.com/spf13/cobra"
1616
"gopkg.in/src-d/go-git.v4"
17+
"gopkg.in/src-d/go-git.v4/plumbing"
1718
"gopkg.in/src-d/go-git.v4/storage/memory"
1819
)
1920

@@ -25,11 +26,15 @@ type (
2526
// NewHiringSendCmd creates a new send hiring test command
2627
func NewHiringSendCmd(ctx context.Context) *cobra.Command {
2728
cmd := &cobra.Command{
28-
Use: "send [username] [repo]",
29-
Short: "Creates a new hellofresh hiring test",
30-
Long: `Creates a new hellofresh hiring test based on the rules defined on your .github.toml`,
29+
Use: "send [username] [repo] [branch]",
30+
Short: "Creates a new HelloFresh hiring test",
31+
Long: `Creates a new HelloFresh hiring test based on the rules defined on your .github.toml`,
3132
RunE: func(cmd *cobra.Command, args []string) error {
32-
return RunCreateTestRepo(ctx, args[0], args[1])
33+
branch := plumbing.Master
34+
if len(args) > 2 {
35+
branch = plumbing.ReferenceName("refs/heads/" + args[2])
36+
}
37+
return RunCreateTestRepo(ctx, args[0], args[1], branch)
3338
},
3439
Args: func(cmd *cobra.Command, args []string) error {
3540
if len(args) < 1 || args[0] == "" {
@@ -48,7 +53,7 @@ func NewHiringSendCmd(ctx context.Context) *cobra.Command {
4853
}
4954

5055
// RunCreateTestRepo runs the command to create a new hiring test repository
51-
func RunCreateTestRepo(ctx context.Context, candidate string, testRepo string) error {
56+
func RunCreateTestRepo(ctx context.Context, candidate string, testRepo string, reference plumbing.ReferenceName) error {
5257
var err error
5358

5459
logger := log.WithContext(ctx)
@@ -93,8 +98,9 @@ func RunCreateTestRepo(ctx context.Context, candidate string, testRepo string) e
9398

9499
logger.Info("Cloning repository...")
95100
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
96-
Progress: os.Stdout,
97-
URL: fmt.Sprintf("https://%s@github.com/%s/%s", cfg.GithubTestOrg.Token, org, testRepo),
101+
Progress: os.Stdout,
102+
URL: fmt.Sprintf("https://%s@github.com/%s/%s", cfg.GithubTestOrg.Token, org, testRepo),
103+
ReferenceName: reference,
98104
})
99105
if err != nil {
100106
return errwrap.Wrapf("error cloning to repository: {{err}}", err)

0 commit comments

Comments
 (0)