Skip to content

Commit

Permalink
internal/civisibility: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyredondo committed Oct 15, 2024
1 parent 9f371ec commit 5e4eaa4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion internal/civisibility/utils/environmentTags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func createCITagsMap() map[string]string {
log.Debug("civisibility: test session name: %v", localTags[constants.TestSessionName])

// Populate missing git data
gitData, _ := GetLocalGitData()
gitData, _ := getLocalGitData()

// Populate Git metadata from the local Git repository if not already present in localTags
if _, ok := localTags[constants.CIWorkspacePath]; !ok {
Expand Down
10 changes: 5 additions & 5 deletions internal/civisibility/utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ func GetGitVersion() (major int, minor int, patch int, error error) {
return major, minor, patch, nil
}

// GetLocalGitData retrieves information about the local Git repository from the current HEAD.
// getLocalGitData retrieves information about the local Git repository from the current HEAD.
// It gathers details such as the repository URL, current branch, latest commit SHA, author and committer details, and commit message.
//
// Returns:
//
// A localGitData struct populated with the retrieved Git data.
// An error if any Git command fails or the retrieved data is incomplete.
func GetLocalGitData() (localGitData, error) {
func getLocalGitData() (localGitData, error) {
gitData := localGitData{}

if !isGitFound() {
Expand Down Expand Up @@ -191,7 +191,7 @@ func UnshallowGitRepository() (bool, error) {
log.Debug("civisibility.unshallow: checking if the repository is a shallow clone")
isAShallowClone, err := isAShallowCloneRepository()
if err != nil {
return false, errors.New(fmt.Sprintf("civisibility.unshallow: error checking if the repository is a shallow clone: %s", err.Error()))
return false, fmt.Errorf("civisibility.unshallow: error checking if the repository is a shallow clone: %s", err.Error())
}

// if the git repo is not a shallow clone, we can return early
Expand All @@ -204,7 +204,7 @@ func UnshallowGitRepository() (bool, error) {
log.Debug("civisibility.unshallow: the repository is a shallow clone, checking if there are more than 2 commits in the logs")
hasMoreThanTwoCommits, err := hasTheGitLogHaveMoreThanTwoCommits()
if err != nil {
return false, errors.New(fmt.Sprintf("civisibility.unshallow: error checking if the git log has more than two commits: %s", err.Error()))
return false, fmt.Errorf("civisibility.unshallow: error checking if the git log has more than two commits: %s", err.Error())
}

// if there are more than 2 commits, we can return early
Expand All @@ -217,7 +217,7 @@ func UnshallowGitRepository() (bool, error) {
log.Debug("civisibility.unshallow: checking the git version")
major, minor, _, err := GetGitVersion()
if err != nil {
return false, errors.New(fmt.Sprintf("civisibility.unshallow: error getting the git version: %s", err.Error()))
return false, fmt.Errorf("civisibility.unshallow: error getting the git version: %s", err.Error())
}
if major < 2 || (major == 2 && minor < 27) {
log.Debug("civisibility.unshallow: the git version is less than 2.27.0")
Expand Down
2 changes: 1 addition & 1 deletion internal/civisibility/utils/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestFilterSensitiveInfo(t *testing.T) {
}

func TestGetLocalGitData(t *testing.T) {
data, err := GetLocalGitData()
data, err := getLocalGitData()

assert.NoError(t, err)
assert.NotEmpty(t, data.SourceRoot)
Expand Down

0 comments on commit 5e4eaa4

Please sign in to comment.