mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 13:34:23 +01:00
Generate the local repoName
To support other URLs than standard github URLs, the repoName is now being generated based on the given URL. Currently supported are formats for HTTP, SSH and local paths. Fixes #4
This commit is contained in:
1 parent
a705784673
commit
9c1ea12d77
2 files changed
+66
-1
No files matched your search
@@ -0,0 +1,54 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGetLocalRepoName(t *testing.T) {
|
||||
cases := []struct{
|
||||
name string
|
||||
input string
|
||||
expected string
|
||||
}{
|
||||
{
|
||||
"Usual github url",
|
||||
"https://github.com/usual/url",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"Usual github url with .git suffix",
|
||||
"https://github.com/usual/url.git",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"personal git url",
|
||||
"git@github.com:url.git",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"personal git url in sub folder",
|
||||
"git@github.com:sub/url.git",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"ssh git url with port",
|
||||
"ssh://git@github.com:2222/sub/url.git",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"local git in sub folder",
|
||||
"local/url.git",
|
||||
"url",
|
||||
},
|
||||
{
|
||||
"local git in same folder",
|
||||
"url.git",
|
||||
"url",
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
actual := getLocalRepoName(c.input)
|
||||
if actual != c.expected {
|
||||
t.Errorf("'%s' failed. Input: '%s'; Expected: '%s'; Got: '%s'", c.input, c.name, c.expected, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user