mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-08-03 03:18:34 +00:00
fix: broken Log Streaming URL when working directory is set to "./" (#2015)
* Replacing . with _ when generating project identifier if project name is not set * Adding test for GenerateProjectJobURL when working dir set to . * Replacing . with _ when generating project identifier if project name is not set * Fixing merge conflicts
This commit is contained in:
@@ -437,7 +437,10 @@ func GetProjectIdentifier(relRepoDir string, projectName string) string {
|
||||
if projectName != "" {
|
||||
return projectName
|
||||
}
|
||||
return strings.ReplaceAll(relRepoDir, "/", "-")
|
||||
// Replace directory separator / with -
|
||||
// Replace . with _ to ensure projects with no project name and root dir set to "." have a valid URL
|
||||
replacer := strings.NewReplacer("/", "-", ".", "_")
|
||||
return replacer.Replace(relRepoDir)
|
||||
}
|
||||
|
||||
// SplitRepoFullName splits a repo full name up into its owner and repo
|
||||
|
||||
@@ -116,6 +116,26 @@ func TestGenerateProjectJobURL_ShouldGenerateURLWithDirectoryAndWorkspaceWhenPro
|
||||
Equals(t, expectedURL, gotURL)
|
||||
}
|
||||
|
||||
func TestGenerateProjectJobURL_ShouldGenerateURLWhenWorkingDirSetToBase(t *testing.T) {
|
||||
router := setupJobsRouter(t)
|
||||
ctx := models.ProjectCommandContext{
|
||||
Pull: models.PullRequest{
|
||||
BaseRepo: models.Repo{
|
||||
Owner: "test-owner",
|
||||
Name: "test-repo",
|
||||
},
|
||||
Num: 1,
|
||||
},
|
||||
RepoRelDir: ".",
|
||||
Workspace: "default",
|
||||
}
|
||||
expectedURL := "http://localhost:4141/jobs/test-owner/test-repo/1/_/default"
|
||||
gotURL, err := router.GenerateProjectJobURL(ctx)
|
||||
Ok(t, err)
|
||||
|
||||
Equals(t, expectedURL, gotURL)
|
||||
}
|
||||
|
||||
func TestGenerateProjectJobURL_ShouldGenerateURLWhenNestedRepo(t *testing.T) {
|
||||
router := setupJobsRouter(t)
|
||||
ctx := models.ProjectCommandContext{
|
||||
|
||||
Reference in New Issue
Block a user