mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 05:23:33 +02:00
update all usage of user.name to user.accountId for privacy migration:
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/
This commit is contained in:
+28
-1
@@ -2,6 +2,7 @@ package jiracmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/coryb/figtree"
|
||||
"github.com/coryb/oreo"
|
||||
@@ -48,7 +49,33 @@ func CmdAssignUsage(cmd *kingpin.CmdClause, opts *AssignOptions) error {
|
||||
|
||||
// CmdAssign will assign an issue to a user
|
||||
func CmdAssign(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AssignOptions) error {
|
||||
err := jira.IssueAssign(o, globals.Endpoint.Value, opts.Issue, opts.Assignee)
|
||||
if globals.JiraDeploymentType.Value == "" {
|
||||
serverInfo, err := jira.ServerInfo(o, globals.Endpoint.Value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
globals.JiraDeploymentType.Value = strings.ToLower(serverInfo.DeploymentType)
|
||||
}
|
||||
|
||||
assignFunc := jira.IssueAssign
|
||||
if globals.JiraDeploymentType.Value == jiracli.CloudDeploymentType {
|
||||
if opts.Assignee != "" && opts.Assignee != "-1" {
|
||||
users, err := jira.UserSearch(o, globals.Endpoint.Value, &jira.UserSearchOptions{
|
||||
Username: opts.Assignee,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(users) > 1 {
|
||||
return fmt.Errorf("Found %d accounts for users with username %q", len(users), opts.Assignee)
|
||||
} else if len(users) == 1 {
|
||||
opts.Assignee = users[0].AccountID
|
||||
}
|
||||
}
|
||||
assignFunc = jira.IssueAssignAccountID
|
||||
}
|
||||
|
||||
err := assignFunc(o, globals.Endpoint.Value, opts.Issue, opts.Assignee)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user