From 4fbdcde57bc7cadff20d42b362033bb79569510d Mon Sep 17 00:00:00 2001 From: Grzegorz Dlugoszewski Date: Thu, 18 Jun 2020 18:45:04 +0200 Subject: [PATCH] Fallback to default branch when cloning instead of parsing --- pkg/dump.go | 2 -- pkg/repo/repo.go | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/dump.go b/pkg/dump.go index af004cd..db9820a 100644 --- a/pkg/dump.go +++ b/pkg/dump.go @@ -2,7 +2,6 @@ package pkg import ( "bufio" - "git-get/pkg/cfg" "os" "strings" @@ -59,7 +58,6 @@ func parseLine(line string) (parsedLine, error) { } parsed.rawurl = parts[0] - parsed.branch = cfg.DefBranch if len(parts) == 2 { parsed.branch = parts[1] } diff --git a/pkg/repo/repo.go b/pkg/repo/repo.go index 887a9a7..7fcdca9 100644 --- a/pkg/repo/repo.go +++ b/pkg/repo/repo.go @@ -32,7 +32,7 @@ type CloneOpts struct { Path string // TODO: should Path be a part of clone opts? Branch string Quiet bool - IgnoreExisting bool // TODO: implement! + IgnoreExisting bool } 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. // Otherwise, assume it's a branch name and check it out. refName := plumbing.ReferenceName(opts.Branch)