Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the version is wrong when give pr #37

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@

var wd *git.Worktree
var remotes []*git.Remote
var version string

Check warning on line 84 in cmd/checkout.go

View check run for this annotation

Codecov / codecov/patch

cmd/checkout.go#L84

Added line #L84 was not covered by tests

if remotes, err = repo.Remotes(); err != nil {
return
Expand All @@ -96,6 +97,7 @@
if wd, err = repo.Worktree(); err == nil {
if c.Flags().Changed("branch") {
c.Printf("Switched to branch '%s'\n", o.branch)
version = o.branch

Check warning on line 100 in cmd/checkout.go

View check run for this annotation

Codecov / codecov/patch

cmd/checkout.go#L100

Added line #L100 was not covered by tests

if err = wd.Checkout(&git.CheckoutOptions{
Branch: plumbing.NewBranchReferenceName(o.branch),
Expand Down Expand Up @@ -131,13 +133,11 @@
err = fmt.Errorf("unable to checkout git branch: %s, error: %v", o.tag, err)
return
}
version = fmt.Sprintf("%d", o.pr)

Check warning on line 136 in cmd/checkout.go

View check run for this annotation

Codecov / codecov/patch

cmd/checkout.go#L136

Added line #L136 was not covered by tests
}

var head *plumbing.Reference
if head, err = repo.Head(); err == nil {
if o.versionOutput != "" {
err = os.WriteFile(o.versionOutput, []byte(strings.TrimPrefix(head.Name().Short(), o.trimVersionPrefix)), 0444)
}
if o.versionOutput != "" {
err = os.WriteFile(o.versionOutput, []byte(strings.TrimPrefix(version, o.trimVersionPrefix)), 0444)

Check warning on line 140 in cmd/checkout.go

View check run for this annotation

Codecov / codecov/patch

cmd/checkout.go#L139-L140

Added lines #L139 - L140 were not covered by tests
}
}
return
Expand Down
Loading