Skip to content

Commit

Permalink
transition: map field name to id
Browse files Browse the repository at this point in the history
this commit allows a user to use the more friendly field.Name when
transitioning to states which require custom field inputs.

Signed-off-by: ldelossa <ldelossa@redhat.com>
  • Loading branch information
ldelossa authored and ldelossa committed Aug 29, 2020
1 parent 6a27e28 commit 3c1c4d9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions jiracmd/transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Transit
return err
}
}

// if issueUpdate contains fields lets see if we can map them
// to their ids
if len(issueUpdate.Fields) > 0 {
fields, err := jira.GetFields(o, globals.Endpoint.Value)
if err != nil {
return err
}
for k, v := range issueUpdate.Fields {
for _, f := range fields {
if f.Name == k {
// re-map to field.id
issueUpdate.Fields[f.ID] = v
delete(issueUpdate.Fields, k)
break
}
}
}
}

return jira.TransitionIssue(o, globals.Endpoint.Value, opts.Issue, &issueUpdate)
})
if err != nil {
Expand Down

0 comments on commit 3c1c4d9

Please sign in to comment.