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

Rename bundle to dump

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-18 15:47:15 +02:00
parent 5a588f22d1
commit 3e9c7644c6
4 changed files with 12 additions and 15 deletions

View File

@@ -9,15 +9,13 @@ import (
"github.com/pkg/errors"
)
var (
ErrInvalidNumberOfElements = errors.New("More than two space-separated 2 elements on the line")
)
var errInvalidNumberOfElements = errors.New("More than two space-separated 2 elements on the line")
// ParseBundleFile opens a given gitgetfile and parses its content into a slice of CloneOpts.
func ParseBundleFile(path string) ([]*repo.CloneOpts, error) {
// ParseDumpFile opens a given gitgetfile and parses its content into a slice of CloneOpts.
func ParseDumpFile(path string) ([]*repo.CloneOpts, error) {
file, err := os.Open(path)
if err != nil {
return nil, errors.Wrapf(err, "Failed opening gitgetfile %s", path)
return nil, errors.Wrapf(err, "Failed opening dump file %s", path)
}
defer file.Close()
@@ -38,13 +36,13 @@ func ParseBundleFile(path string) ([]*repo.CloneOpts, error) {
return opts, nil
}
// parseLine splits a gitgetfile line into space-separated segments.
// parseLine splits a dump file line into space-separated segments.
// First part is the URL to clone. Second, optional, is the branch (or tag) to checkout after cloning
func parseLine(line string) (*repo.CloneOpts, error) {
parts := strings.Split(line, " ")
if len(parts) > 2 {
return nil, ErrInvalidNumberOfElements
return nil, errInvalidNumberOfElements
}
url, err := ParseURL(parts[0])
@@ -60,7 +58,7 @@ func parseLine(line string) (*repo.CloneOpts, error) {
return &repo.CloneOpts{
URL: url,
Branch: branch,
// When cloning a bundle we ignore errors about already cloned repos
// When cloning a bundle we ignore errors about already cloned repos.
IgnoreExisting: true,
}, nil
}

View File

@@ -28,12 +28,12 @@ func TestParsingRefs(t *testing.T) {
{
line: "https://github.com/grdl/git-get master branch",
wantBranch: "",
wantErr: ErrInvalidNumberOfElements,
wantErr: errInvalidNumberOfElements,
},
{
line: "https://github.com",
wantBranch: "",
wantErr: ErrEmptyURLPath,
wantErr: errEmptyURLPath,
},
}

View File

@@ -44,7 +44,7 @@ func cloneSingleRepo(c *GetCfg) error {
}
func cloneDumpFile(c *GetCfg) error {
opts, err := ParseBundleFile(c.Dump)
opts, err := ParseDumpFile(c.Dump)
if err != nil {
return err
}

View File

@@ -11,8 +11,7 @@ import (
"github.com/spf13/viper"
)
// ErrEmptyURLPath is an error indicating that the path part of URL is empty.
var ErrEmptyURLPath = errors.New("Parsed URL path is empty")
var errEmptyURLPath = errors.New("Parsed URL path is empty")
// scpSyntax matches the SCP-like addresses used by the ssh protocol (eg, [user@]host.xz:path/to/repo.git/).
// See: https://golang.org/src/cmd/go/internal/get/vcs.go
@@ -36,7 +35,7 @@ func ParseURL(rawURL string) (url *urlpkg.URL, err error) {
}
if url.Host == "" && url.Path == "" {
return nil, ErrEmptyURLPath
return nil, errEmptyURLPath
}
if url.Scheme == "git+ssh" {