mirror of
https://github.com/grdl/git-get.git
synced 2026-02-04 16:49:43 +00:00
Fallback to default branch when cloning instead of parsing
This commit is contained in:
@@ -2,7 +2,6 @@ package pkg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"git-get/pkg/cfg"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@ func parseLine(line string) (parsedLine, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parsed.rawurl = parts[0]
|
parsed.rawurl = parts[0]
|
||||||
parsed.branch = cfg.DefBranch
|
|
||||||
if len(parts) == 2 {
|
if len(parts) == 2 {
|
||||||
parsed.branch = parts[1]
|
parsed.branch = parts[1]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ type CloneOpts struct {
|
|||||||
Path string // TODO: should Path be a part of clone opts?
|
Path string // TODO: should Path be a part of clone opts?
|
||||||
Branch string
|
Branch string
|
||||||
Quiet bool
|
Quiet bool
|
||||||
IgnoreExisting bool // TODO: implement!
|
IgnoreExisting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func Clone(opts *CloneOpts) (*Repo, error) {
|
func Clone(opts *CloneOpts) (*Repo, error) {
|
||||||
@@ -51,6 +51,10 @@ func Clone(opts *CloneOpts) (*Repo, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.Branch == "" {
|
||||||
|
opts.Branch = cfg.DefBranch
|
||||||
|
}
|
||||||
|
|
||||||
// If branch name is actually a tag (ie. is prefixed with refs/tags) - check out that tag.
|
// If branch name is actually a tag (ie. is prefixed with refs/tags) - check out that tag.
|
||||||
// Otherwise, assume it's a branch name and check it out.
|
// Otherwise, assume it's a branch name and check it out.
|
||||||
refName := plumbing.ReferenceName(opts.Branch)
|
refName := plumbing.ReferenceName(opts.Branch)
|
||||||
|
|||||||
Reference in New Issue
Block a user