diff --git a/pkg/utils/git.go b/pkg/utils/git.go index 0a3cbff..aca3a62 100644 --- a/pkg/utils/git.go +++ b/pkg/utils/git.go @@ -20,8 +20,10 @@ type GitTagDetails struct { CommitDate time.Time } +// Clone a git repo into a local directory. +// Credentials need to be specified by embedding in gitRemote url. +// TODO: this pattern may not work on Bitbucket/GitLab func GitClone(parentPath string, repositoryName string, gitRemote string) (string, error) { - //TODO: credentials may need to be specified absPath, aerr := filepath.Abs(path.Join(parentPath, repositoryName)) if aerr != nil { return "", aerr diff --git a/pkg/utils/git_test.go b/pkg/utils/git_test.go index 3aa4399..dc6ef8b 100644 --- a/pkg/utils/git_test.go +++ b/pkg/utils/git_test.go @@ -246,6 +246,20 @@ func TestGitLatestTaggedCommit(t *testing.T) { } +func TestGitLatestTaggedCommit_InvalidDirectory(t *testing.T) { + t.Parallel() + + //setup + dirPath := path.Join("this", "path", "does", "not", "exist") + + //test + tag, ferr := utils.GitLatestTaggedCommit(dirPath) + + //assert + require.Error(t, ferr) + require.Empty(t, tag) +} + func TestGitGenerateChangelog(t *testing.T) { t.Parallel()