diff --git a/pkg/bundle.go b/pkg/dump.go similarity index 68% rename from pkg/bundle.go rename to pkg/dump.go index fc40f1c..eee51fd 100644 --- a/pkg/bundle.go +++ b/pkg/dump.go @@ -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 } diff --git a/pkg/bundle_test.go b/pkg/dump_test.go similarity index 93% rename from pkg/bundle_test.go rename to pkg/dump_test.go index a29e0ea..722756a 100644 --- a/pkg/bundle_test.go +++ b/pkg/dump_test.go @@ -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, }, } diff --git a/pkg/get.go b/pkg/get.go index 6e3aa95..fed520b 100644 --- a/pkg/get.go +++ b/pkg/get.go @@ -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 } diff --git a/pkg/url.go b/pkg/url.go index 4398a2c..3d97171 100644 --- a/pkg/url.go +++ b/pkg/url.go @@ -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" {