mirror of
https://github.com/Threnklyn/jira.git
synced 2026-06-07 13:33:32 +02:00
* use forked yaml.v2 so as to not lose line terminations present in jira fields
* adding a |~ literal yaml syntax to just chomp a single newline (again to preserve existing formatting in jira fields) * for indent/comment allow for unicode line termination characters that yaml will use for parsing
This commit is contained in:
+3
-5
@@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/kballard/go-shellquote"
|
"github.com/kballard/go-shellquote"
|
||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/coryb/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/cookiejar"
|
"net/http/cookiejar"
|
||||||
@@ -250,10 +250,7 @@ func (c *Cli) editTemplate(template string, tmpFilePrefix string, templateData m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editing := true
|
editing := c.getOptBool("edit", true)
|
||||||
if val, ok := c.opts["edit"].(bool); ok && !val {
|
|
||||||
editing = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tmpFileNameOrig := fmt.Sprintf("%s.orig", tmpFileName)
|
tmpFileNameOrig := fmt.Sprintf("%s.orig", tmpFileName)
|
||||||
copyFile(tmpFileName, tmpFileNameOrig)
|
copyFile(tmpFileName, tmpFileNameOrig)
|
||||||
@@ -275,6 +272,7 @@ func (c *Cli) editTemplate(template string, tmpFilePrefix string, templateData m
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
diff := exec.Command("diff", "-q", tmpFileNameOrig, tmpFileName)
|
diff := exec.Command("diff", "-q", tmpFileNameOrig, tmpFileName)
|
||||||
// if err == nil then diff found no changes
|
// if err == nil then diff found no changes
|
||||||
if err := diff.Run(); err == nil {
|
if err := diff.Run(); err == nil {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ const default_edit_template = `# issue: {{ .key }}
|
|||||||
update:
|
update:
|
||||||
comment:
|
comment:
|
||||||
- add:
|
- add:
|
||||||
body: |
|
body: |~
|
||||||
{{ or .overrides.comment "" | indent 10 }}
|
{{ or .overrides.comment "" | indent 10 }}
|
||||||
fields:
|
fields:
|
||||||
summary: {{ or .overrides.summary .fields.summary }}
|
summary: {{ or .overrides.summary .fields.summary }}
|
||||||
@@ -71,7 +71,7 @@ fields:
|
|||||||
- name: {{ .overrides.watcher}}{{end}}
|
- name: {{ .overrides.watcher}}{{end}}
|
||||||
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
|
priority: # Values: {{ range .meta.fields.priority.allowedValues }}{{.name}}, {{end}}
|
||||||
name: {{ or .overrides.priority .fields.priority.name }}
|
name: {{ or .overrides.priority .fields.priority.name }}
|
||||||
description: |
|
description: |~
|
||||||
{{ or .overrides.description (or .fields.description "") | indent 4 }}
|
{{ or .overrides.description (or .fields.description "") | indent 4 }}
|
||||||
# comments:
|
# comments:
|
||||||
# {{ range .fields.comment.comments }} - | # {{.author.name}} at {{.created}}
|
# {{ range .fields.comment.comments }} - | # {{.author.name}} at {{.created}}
|
||||||
@@ -94,7 +94,7 @@ const default_create_template = `fields:
|
|||||||
name: {{ or .overrides.priority "unassigned" }}
|
name: {{ or .overrides.priority "unassigned" }}
|
||||||
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
|
components: # Values: {{ range .meta.fields.components.allowedValues }}{{.name}}, {{end}}{{ range split "," (or .overrides.components "")}}
|
||||||
- name: {{ . }}{{end}}
|
- name: {{ . }}{{end}}
|
||||||
description: |
|
description: |~
|
||||||
{{ or .overrides.description "" | indent 4 }}
|
{{ or .overrides.description "" | indent 4 }}
|
||||||
assignee:
|
assignee:
|
||||||
name: {{ or .overrides.assignee "" }}
|
name: {{ or .overrides.assignee "" }}
|
||||||
@@ -106,14 +106,14 @@ const default_create_template = `fields:
|
|||||||
- name:
|
- name:
|
||||||
`
|
`
|
||||||
|
|
||||||
const default_comment_template = `body: |
|
const default_comment_template = `body: |~
|
||||||
{{ or .overrides.comment "" | indent 2 }}
|
{{ or .overrides.comment "" | indent 2 }}
|
||||||
`
|
`
|
||||||
|
|
||||||
const default_transition_template = `update:
|
const default_transition_template = `update:
|
||||||
comment:
|
comment:
|
||||||
- add:
|
- add:
|
||||||
body: |
|
body: |~
|
||||||
{{ or .overrides.comment "" | indent 10 }}
|
{{ or .overrides.comment "" | indent 10 }}
|
||||||
fields:{{if .meta.fields.assignee}}
|
fields:{{if .meta.fields.assignee}}
|
||||||
assignee:
|
assignee:
|
||||||
|
|||||||
+14
-3
@@ -125,15 +125,26 @@ func runTemplate(templateContent string, data interface{}, out io.Writer) error
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indent": func(spaces int, content string) string {
|
"indent": func(spaces int, content string) string {
|
||||||
indent := make([]byte, spaces+1, spaces+1)
|
indent := make([]rune, spaces+1, spaces+1)
|
||||||
indent[0] = '\n'
|
indent[0] = '\n'
|
||||||
for i := 1; i < spaces+1; i += 1 {
|
for i := 1; i < spaces+1; i += 1 {
|
||||||
indent[i] = ' '
|
indent[i] = ' '
|
||||||
}
|
}
|
||||||
return strings.Replace(content, "\n", string(indent), -1)
|
|
||||||
|
lineSeps := []rune{'\n', '\u0085', '\u2028', '\u2029'}
|
||||||
|
for _, sep := range lineSeps {
|
||||||
|
indent[0] = sep
|
||||||
|
content = strings.Replace(content, string(sep), string(indent), -1)
|
||||||
|
}
|
||||||
|
return content
|
||||||
|
|
||||||
},
|
},
|
||||||
"comment": func(content string) string {
|
"comment": func(content string) string {
|
||||||
return strings.Replace(content, "\n", "\n# ", -1)
|
lineSeps := []rune{'\n', '\u0085', '\u2028', '\u2029'}
|
||||||
|
for _, sep := range lineSeps {
|
||||||
|
content = strings.Replace(content, string(sep), string([]rune{sep, '#', ' '}), -1)
|
||||||
|
}
|
||||||
|
return content
|
||||||
},
|
},
|
||||||
"color": func(color string) string {
|
"color": func(color string) string {
|
||||||
return ansi.ColorCode(color)
|
return ansi.ColorCode(color)
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/Netflix-Skunkworks/go-jira/jira/cli"
|
"github.com/Netflix-Skunkworks/go-jira/jira/cli"
|
||||||
"github.com/coryb/optigo"
|
"github.com/coryb/optigo"
|
||||||
"github.com/op/go-logging"
|
"github.com/op/go-logging"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/coryb/yaml.v2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|||||||
Reference in New Issue
Block a user