Skip to content

Commit

Permalink
Use org URL name, not display name when creating projects and project…
Browse files Browse the repository at this point in the history
… files.
  • Loading branch information
mitchell-as committed Sep 14, 2023
1 parent 94fe1fe commit 2733e65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion internal/runners/fork/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ func determineOwner(username string, prompter prompt.Prompter) (string, error) {
}

options := make([]string, len(orgs))
displayNameToURLNameMap := make(map[string]string)
for i, org := range orgs {
options[i] = org.DisplayName
displayNameToURLNameMap[org.DisplayName] = org.URLname
}
options = append([]string{username}, options...)

r, err := prompter.Select(locale.Tl("fork_owner_title", "Owner"), locale.Tl("fork_select_org", "Who should the new project belong to?"), options, new(string))
return r, err
owner, exists := displayNameToURLNameMap[r]
if !exists {
return "", errs.New("Selected organization does not have a URL name")
}
return owner, err
}
4 changes: 2 additions & 2 deletions internal/runners/initialize/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func (r *Initialize) Run(params *RunParams) (rerr error) {
return errs.Wrap(err, "Unable to get the user's writable orgs")
}
for _, org := range orgs {
if strings.EqualFold(org.DisplayName, params.Namespace.Owner) {
owner = org.DisplayName
if strings.EqualFold(org.URLname, params.Namespace.Owner) {
owner = org.URLname
break
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmdlets/checkout/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (r *Checkout) Run(ns *project.Namespaced, branchName, cachePath, targetPath
if len(owners) == 0 {
return "", locale.NewInputError("err_no_org_name", "Your project's organization name could not be found")
}
owner := owners[0].DisplayName
owner := owners[0].URLName

// Create the config file, if the repo clone didn't already create it
configFile := filepath.Join(path, constants.ConfigFileName)
Expand Down

0 comments on commit 2733e65

Please sign in to comment.