Skip to content

Commit

Permalink
pr create: allow git push step to prompt on stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Sep 21, 2022
1 parent b82884a commit 6ca9406
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ func CommitBody(sha string) (string, error) {
}

// Push publishes a git ref to a remote and sets up upstream configuration
func Push(remote string, ref string, cmdOut, cmdErr io.Writer) error {
func Push(remote string, ref string, cmdIn io.ReadCloser, cmdOut, cmdErr io.Writer) error {
pushCmd, err := GitCommand("push", "--set-upstream", remote, ref)
if err != nil {
return err
}
pushCmd.Stdin = cmdIn
pushCmd.Stdout = cmdOut
pushCmd.Stderr = cmdErr
return run.PrepareCmd(pushCmd).Run()
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/pr/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,9 @@ func handlePush(opts CreateOptions, ctx CreateContext) error {
r := NewRegexpWriter(opts.IO.ErrOut, gitPushRegexp, "")
defer r.Flush()
cmdErr := r
cmdIn := opts.IO.In
cmdOut := opts.IO.Out
if err := git.Push(headRemote.Name, fmt.Sprintf("HEAD:%s", ctx.HeadBranch), cmdOut, cmdErr); err != nil {
if err := git.Push(headRemote.Name, fmt.Sprintf("HEAD:%s", ctx.HeadBranch), cmdIn, cmdOut, cmdErr); err != nil {
if didForkRepo && pushTries < maxPushTries {
pushTries++
// first wait 2 seconds after forking, then 4s, then 6s
Expand Down

0 comments on commit 6ca9406

Please sign in to comment.