Skip to content

Commit ca4268a

Browse files
code review comments incorporated
1 parent 37b91cd commit ca4268a

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

pkg/git/Util.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,8 @@ const (
4646

4747
func GetProjectName(url string) string {
4848
//if url = https://github.com/devtron-labs/git-sensor.git then it will return git-sensor
49-
// Split the URL by dots
50-
parts := strings.Split(url, "/")
51-
52-
// Extract the last part after the last slash
53-
projectName := parts[len(parts)-1]
54-
55-
// Split the project name by dots
56-
projectNameParts := strings.Split(projectName, ".")
57-
58-
// Check if the last part is "git" and exclude it
59-
if projectNameParts[len(projectNameParts)-1] == "git" {
60-
projectName = strings.Join(projectNameParts[:len(projectNameParts)-1], ".")
61-
} else {
62-
projectName = strings.Join(projectNameParts, ".")
63-
}
64-
65-
return projectName
49+
url = url[strings.LastIndex(url, "/")+1:]
50+
return strings.TrimSuffix(url, ".git")
6651
}
6752
func GetCheckoutPath(url string, cloneLocation string) string {
6853
//url= https://github.com/devtron-labs/git-sensor.git cloneLocation= git-base/1/github.com/prakash100198

0 commit comments

Comments
 (0)