6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 16:49:43 +00:00

Implement ignoreExisting flag and set default branch also for dump cloning

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-18 17:30:42 +02:00
parent 330cbf5840
commit e800652a6e
2 changed files with 7 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package pkg
import ( import (
"bufio" "bufio"
"git-get/pkg/cfg"
"os" "os"
"strings" "strings"
@@ -58,6 +59,7 @@ 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]
} }

View File

@@ -73,6 +73,11 @@ func Clone(opts *CloneOpts) (*Repo, error) {
repo, err := git.PlainClone(opts.Path, false, gitOpts) repo, err := git.PlainClone(opts.Path, false, gitOpts)
if err != nil { if err != nil {
if opts.IgnoreExisting && errors.Is(err, git.ErrRepositoryAlreadyExists) {
return nil, nil
}
return nil, errors.Wrap(err, "Failed cloning repo") return nil, errors.Wrap(err, "Failed cloning repo")
} }