Panic if tracking ref can't be reconstructed
This commit is contained in:
parent
3ae4e5da20
commit
dc077dc09b
2 changed files with 12 additions and 16 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -65,17 +64,6 @@ func (r TrackingRef) String() string {
|
|||
return "refs/remotes/" + r.RemoteName + "/" + r.BranchName
|
||||
}
|
||||
|
||||
func ParseTrackingRef(text string) (TrackingRef, error) {
|
||||
parts := strings.SplitN(string(text), "/", 4)
|
||||
if len(parts) != 4 {
|
||||
return TrackingRef{}, fmt.Errorf("invalid tracking ref: %s", text)
|
||||
}
|
||||
return TrackingRef{
|
||||
RemoteName: parts[2],
|
||||
BranchName: parts[3],
|
||||
}, nil
|
||||
}
|
||||
|
||||
type Commit struct {
|
||||
Sha string
|
||||
Title string
|
||||
|
|
|
|||
|
|
@ -555,10 +555,7 @@ func determineTrackingBranch(gitClient *git.Client, remotes ghContext.Remotes, l
|
|||
continue
|
||||
}
|
||||
// Otherwise we can parse the returned ref into a tracking ref and return that
|
||||
trackingRef, err := git.ParseTrackingRef(r.Name)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
trackingRef := mustParseTrackingRef(r.Name)
|
||||
return &trackingRef
|
||||
}
|
||||
}
|
||||
|
|
@ -566,6 +563,17 @@ func determineTrackingBranch(gitClient *git.Client, remotes ghContext.Remotes, l
|
|||
return nil
|
||||
}
|
||||
|
||||
func mustParseTrackingRef(text string) git.TrackingRef {
|
||||
parts := strings.SplitN(string(text), "/", 4)
|
||||
if len(parts) != 4 {
|
||||
panic(fmt.Errorf("invalid tracking ref: %s", text))
|
||||
}
|
||||
return git.TrackingRef{
|
||||
RemoteName: parts[2],
|
||||
BranchName: parts[3],
|
||||
}
|
||||
}
|
||||
|
||||
func NewIssueState(ctx CreateContext, opts CreateOptions) (*shared.IssueMetadataState, error) {
|
||||
var milestoneTitles []string
|
||||
if opts.Milestone != "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue