Skip to content

Commit

Permalink
FWI-5332 - CI plugin - Remove .git suffix from repo name (#833)
Browse files Browse the repository at this point in the history
* fix removing git suffix

* bump version and changelog

* trigger-ci

* fix go mod

* bump version.txt

* add more tests
  • Loading branch information
vitorvezani authored Nov 14, 2023
1 parent 3e310e6 commit 9a9042b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions plugins/ci/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 5.2.5
* Fix removing `.git` from repository name

## 5.2.4
* Update to go 1.21

Expand Down
3 changes: 2 additions & 1 deletion plugins/ci/pkg/ci/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/fairwindsops/insights-plugins/plugins/ci/pkg/models"
Expand Down Expand Up @@ -134,7 +135,7 @@ func extractRepoNameFromOrigin(origin string) string {
repoNameSplit := strings.Split(repoName, ":")
repoName = repoNameSplit[len(repoNameSplit)-1]
}
return strings.TrimSuffix(repoName, ".git")
return strings.TrimSuffix(repoName, filepath.Ext(repoName))
}

type hint struct {
Expand Down
2 changes: 2 additions & 0 deletions plugins/ci/pkg/ci/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
)

func TestExtractRepoNameFromOrigin(t *testing.T) {
assert.Equal(t, "FairwindsOps/insights-plugins", extractRepoNameFromOrigin("[email protected]:FairwindsOps/insights-plugins"))
assert.Equal(t, "FairwindsOps/insights-plugins", extractRepoNameFromOrigin("[email protected]:FairwindsOps/insights-plugins.git"))
assert.Equal(t, "FairwindsOps/insights-plugins", extractRepoNameFromOrigin("[email protected]:FairwindsOps/insights-plugins.git\n"))
assert.Equal(t, "", extractRepoNameFromOrigin(""))
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/ci/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.2.4
5.2.5

0 comments on commit 9a9042b

Please sign in to comment.