mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-19 04:33:28 +02:00
add resolution to dup'd issues when necessary
This commit is contained in:
+14
-2
@@ -72,19 +72,31 @@ func CmdDup(o *oreo.Client, globals *jiracli.GlobalOptions, opts *DupOptions) er
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, trans := range []string{"close", "done", "start", "stop"} {
|
||||
for _, trans := range []string{"close", "done", "cancel", "start", "stop"} {
|
||||
transMeta := meta.Transitions.Find(trans)
|
||||
if transMeta != nil {
|
||||
issueUpdate := jiradata.IssueUpdate{
|
||||
Transition: transMeta,
|
||||
}
|
||||
resolution := defaultResolution(transMeta)
|
||||
if resolution != "" {
|
||||
issueUpdate.Fields = map[string]interface{}{
|
||||
"resolution": map[string]interface{}{
|
||||
"name": resolution,
|
||||
},
|
||||
}
|
||||
}
|
||||
if err = jira.TransitionIssue(o, globals.Endpoint.Value, opts.InwardIssue.Key, &issueUpdate); err != nil {
|
||||
return err
|
||||
}
|
||||
// if we just started the issue now we need to stop it
|
||||
if trans != "start" {
|
||||
break
|
||||
}
|
||||
// if we are here then we must be stopping, so need to reset the meta
|
||||
meta, err = jira.GetIssueTransitions(o, globals.Endpoint.Value, opts.InwardIssue.Key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,21 @@ func CmdTransitionUsage(cmd *kingpin.CmdClause, opts *TransitionOptions) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func defaultResolution(transMeta *jiradata.Transition) string {
|
||||
if resField, ok := transMeta.Fields["resolution"]; ok {
|
||||
for _, allowedValueRaw := range resField.AllowedValues {
|
||||
if allowedValue, ok := allowedValueRaw.(map[string]interface{}); ok {
|
||||
if allowedValue["name"] == "Fixed" {
|
||||
return "Fixed"
|
||||
} else if allowedValue["name"] == "Done" {
|
||||
return "Done"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// CmdTransition will move state of the given issue to the given transtion
|
||||
func CmdTransition(o *oreo.Client, globals *jiracli.GlobalOptions, opts *TransitionOptions) error {
|
||||
issueData, err := jira.GetIssue(o, globals.Endpoint.Value, opts.Issue, nil)
|
||||
|
||||
Reference in New Issue
Block a user