Skip to content

Commit

Permalink
refs Songmu#164, Refer to the next version with command
Browse files Browse the repository at this point in the history
  • Loading branch information
k2tzumi committed Dec 29, 2023
1 parent f8cd72e commit c4aec81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package tagpr

import (
"bytes"
"fmt"
"io"
"log"
"os"
"os/exec"
"strings"
)
Expand All @@ -20,14 +22,17 @@ func (c *commander) getGitPath() string {
return c.gitPath
}

func (c *commander) Cmd(prog string, args ...string) (string, string, error) {
func (c *commander) Cmd(prog string, from, to *semv, args ...string) (string, string, error) {
log.Println(prog, args)

var (
outBuf bytes.Buffer
errBuf bytes.Buffer
)
cmd := exec.Command(prog, args...)
if from != nil && to != nil {
cmd.Env = append(os.Environ(), fmt.Sprintf("CURRENT_VERSION=%s", from.Tag()), fmt.Sprintf("NEXT_VERSION=%s", to.Tag()))
}
cmd.Stdout = io.MultiWriter(&outBuf, c.outStream)
cmd.Stderr = io.MultiWriter(&errBuf, c.errStream)
if c.dir != "" {
Expand All @@ -38,5 +43,5 @@ func (c *commander) Cmd(prog string, args ...string) (string, string, error) {
}

func (c *commander) Git(args ...string) (string, string, error) {
return c.Cmd(c.getGitPath(), args...)
return c.Cmd(c.getGitPath(), nil, nil, args...)
}
2 changes: 1 addition & 1 deletion tagpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ OUT:
progArgs = []string{"-c", prog}
prog = "sh"
}
tp.c.Cmd(prog, progArgs...)
tp.c.Cmd(prog, currVer, nextVer, progArgs...)
}

if len(vfiles) > 0 && vfiles[0] != "" {
Expand Down

0 comments on commit c4aec81

Please sign in to comment.