Skip to content

Commit

Permalink
Now uses push --follow-tags (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
FollowTheProcess committed May 14, 2023
1 parent ce17e84 commit f330e46
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 59 deletions.
9 changes: 1 addition & 8 deletions cli/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,8 @@ func (a *App) doBump(current, next semver.Version, message string, push bool) er

// If push, push the tag
if push {
if a.replace {
msg.Finfo(a.stdout, "Pushing bump commit")
stdout, err = git.Push()
if err != nil {
return errors.New(stdout)
}
}
msg.Finfo(a.stdout, "Pushing tag %s", next.Tag())
stdout, err = git.PushTag(next.Tag())
stdout, err = git.Push()
if err != nil {
return errors.New(stdout)
}
Expand Down
12 changes: 1 addition & 11 deletions git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ func Add() error {

// Push performs a git push to the configured remote.
func Push() (string, error) {
cmd := gitCommand("git", "push")
out, err := cmd.CombinedOutput()
if err != nil {
return string(out), err
}
return string(out), nil
}

// PushTag pushes a certain tag to the configured remote.
func PushTag(tag string) (string, error) {
cmd := gitCommand("git", "push", "origin", tag)
cmd := gitCommand("git", "push", "--follow-tags", "--atomic")
out, err := cmd.CombinedOutput()
if err != nil {
return string(out), err
Expand Down
40 changes: 0 additions & 40 deletions git/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,46 +153,6 @@ func TestPush(t *testing.T) {
}
}

func TestPushTag(t *testing.T) {
tests := []struct {
name string
stdout string
status int
wantErr bool
}{
{
name: "happy",
stdout: "success",
status: 0,
wantErr: false,
},
{
name: "sad",
stdout: "I failed!",
status: 1,
wantErr: true,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
mockExitStatus = tt.status
mockStdout = tt.stdout
gitCommand = fakeExecCommand
defer func() { gitCommand = exec.Command }()

out, err := PushTag("v1.2.3")
if (err != nil) != tt.wantErr {
t.Fatalf("PushTag() returned %v, wanted %v", err, tt.wantErr)
}

if out != tt.stdout {
t.Errorf("PushTag stdout was %q, wanted %q", out, tt.stdout)
}
})
}
}

func TestListTags(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit f330e46

Please sign in to comment.