Skip to content
Open
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
11 changes: 6 additions & 5 deletions internal/pipeline/resolver/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ func parsePipelineArg(arg string, conf *config.Config) (org, pipeline string) {
return normalizeSlug(org), normalizeSlug(pipeline)
}

// normalizeSlug converts user input to a valid Buildkite slug. Slugs may only contain
// lowercase letters, numbers and dashes, so this is a no-op on anything already valid.
// It allows passing a name like "my_pipeline" (eg. from a repository directory name)
// and matching the "my-pipeline" slug Buildkite derives from it.
// normalizeSlug converts user input to a valid Buildkite slug. Slugs may contain
// letters (of any case), numbers and dashes, so this is a no-op on anything already
// valid. It allows passing a name like "my_pipeline" (eg. from a repository directory
// name) and matching the "my-pipeline" slug Buildkite derives from it. Casing is
// preserved since Buildkite organization and pipeline slugs may be mixed case.
func normalizeSlug(s string) string {
return strings.ToLower(strings.ReplaceAll(s, "_", "-"))
return strings.ReplaceAll(s, "_", "-")
}
6 changes: 3 additions & 3 deletions internal/pipeline/resolver/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func TestParsePipelineArg(t *testing.T) {
org: "testing",
pipeline: "shared-gem",
},
"uppercase_normalized_to_lowercase": {
"casing_preserved": {
url: "My_Org/Shared_Gem",
org: "my-org",
pipeline: "shared-gem",
org: "My-Org",
pipeline: "Shared-Gem",
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/pipeline/resolver/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func TestWithOrg(t *testing.T) {
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if p.Org != "override-org" {
t.Fatalf("expected org override-org, got %s", p.Org)
if p.Org != "Override-Org" {
t.Fatalf("expected org Override-Org, got %s", p.Org)
}
})
}