diff --git a/CHANGELOG.md b/CHANGELOG.md index ccbed34..234cb6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Utils Changelog +## v0.0.8 + +* Updated `GetFileContent` in `azuredevops` to allow specifying of the version type. + ## v.0.0.7 * Allowed configuring of filename in `GetFileContent` in `azuredevops`. diff --git a/azuredevops/git.go b/azuredevops/git.go index f61283e..88cf098 100644 --- a/azuredevops/git.go +++ b/azuredevops/git.go @@ -1,19 +1,33 @@ package azuredevops import ( + "fmt" + "github.com/microsoft/azure-devops-go-api/azuredevops/git" ) // GetFileContent gets content in a file over API. -func (a *AzureDevOps) GetFileContent(projectName string, repoName string, version string, filepath string) (*git.GitItem, error) { +func (a *AzureDevOps) GetFileContent(projectName string, repoName string, version string, filepath string, versionType string) (*git.GitItem, error) { client, err := git.NewClient(a.ctx, a.connection) if err != nil { return nil, err } + var vt git.GitVersionType + switch versionType { + case "branch": + vt = git.GitVersionTypeValues.Branch + case "commit": + vt = git.GitVersionTypeValues.Commit + case "tag": + vt = git.GitVersionTypeValues.Tag + default: + return nil, fmt.Errorf("unknown version type: %s", versionType) + } + includeContent := true gitVersionDescriptor := git.GitVersionDescriptor{ - VersionType: &git.GitVersionTypeValues.Tag, + VersionType: &vt, Version: &version, } getItemArgs := git.GetItemArgs{