Skip to content

Commit

Permalink
FTR-101 Choose the version type for the file content. (#9)
Browse files Browse the repository at this point in the history
* FTR-101 Choose the version type for the file content.
  • Loading branch information
CDA0 authored Nov 9, 2023
1 parent fcbb599 commit 2cf266d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
18 changes: 16 additions & 2 deletions azuredevops/git.go
Original file line number Diff line number Diff line change
@@ -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{
Expand Down

0 comments on commit 2cf266d

Please sign in to comment.