Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/pkg/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func InstallProjectDependencies(

// generateGitZipFileURL will return the GitHub zip URL for a templateURL.
func generateGitZipFileURL(httpClient slackhttp.HTTPClient, templateURL string, gitBranch string) string {
zipURL := strings.ReplaceAll(templateURL, ".git", "") + "/archive/refs/heads/"
zipURL := strings.TrimSuffix(templateURL, ".git") + "/archive/refs/heads/"

if gitBranch == "" {
mainURL := zipURL + "main.zip"
Expand Down
18 changes: 18 additions & 0 deletions internal/pkg/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ func Test_generateGitZipFileURL(t *testing.T) {
httpClientMock.On("Get", mock.Anything).Return(nil, fmt.Errorf("HTTPClient error"))
},
},
"Returns the zip URL with .git suffix removed": {
templateURL: "https://github.com/slack-samples/deno-starter-template.git",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📣 This IMO is the case we ought consider as "correct" for the --template flag since it appears on the "HTTPS" tab of the Code dropdown from the sample page:

🔗 https://github.com/slack-samples/deno-starter-template
📺 https://github.com/slack-samples/deno-starter-template.git

FWIW we do not use the .git prefix in sample names but might recommend using the entire URL ending with .git if this is encountered later... Or recommend changing the sample name altogether, though I understand this can cause hassle 😉

gitBranch: "",
expectedURL: "https://github.com/slack-samples/deno-starter-template/archive/refs/heads/main.zip",
setupHTTPClientMock: func(httpClientMock *slackhttp.HTTPClientMock) {
res := slackhttp.MockHTTPResponse(http.StatusOK, "OK")
httpClientMock.On("Get", mock.Anything).Return(res, nil)
},
},
"Returns the zip URL with .git inside URL preserved": {
templateURL: "https://github.com/slack-samples/deno.git-starter-template",
gitBranch: "",
expectedURL: "https://github.com/slack-samples/deno.git-starter-template/archive/refs/heads/main.zip",
setupHTTPClientMock: func(httpClientMock *slackhttp.HTTPClientMock) {
res := slackhttp.MockHTTPResponse(http.StatusOK, "OK")
httpClientMock.On("Get", mock.Anything).Return(res, nil)
},
},
}
for name, tt := range tests {
t.Run(name, func(t *testing.T) {
Expand Down
Loading