-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update default edit template, and copy the overrides into the opts #13
Conversation
* login * editmeta ISSUE * edit ISSUE * issuetypes [-p PROJECT] * createmeta [-p PROJECT] [-i ISSUETYPE] * transitions ISSUE make --template argumetn work
* create * dups * blocks * watch
updated edit template to allow for -o overrides
fix looking for generic "create" template
The default view template was failing with this error whenever I tried to view a jira that had no assignee: assignee: 2015-02-16T08:31:58.564-08:00 ERROR [util.go:109] Failed to execute template: template: template:7:20: executing "template" at <.fields.assignee.nam...>: nil pointer evaluating interface {}.name
…o jaybuff-nil-assignee
… your favorite browser
…ment so you can review the comment details while editing
…ira 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
…ypto/ssh/terminal for reading password from stdin
where the template expects them to be.
jira/cli/templates.go
Outdated
@@ -52,12 +52,18 @@ comments: | |||
` | |||
const default_edit_template = `# issue: {{ .key }} | |||
update: | |||
{{if .overrides.comment}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal here is to auto populate the comment if someone used -m "my comment" but still allow someone to manually type in a comment while running "jira edit". So in the case that someone wants to add a comment but does not use "jira edit -m ..." that section of the template needs to exist, so I think it should still look something like:
comment:
- add:
body: |~
{{ or .overrides.comment "" | indent 10 }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think thats fine, the reason I changed it was because it doesn't allow you to do anything without a comment, but thats my case and I could just update my own templates locally.
When I was looking around in there, it seems that our version of jira validates the comment is not just whitespace, and gives us back an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Users should be able to edit an issue without adding a comment (change watchers, change assigned, etc). If you leave the comment body blank go-jira should strip that field from the document submitted to the jira api. There might be a bug with that, the document is fixed in the yamlFixup routine in util.go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just found a bug that would try to post "\n" for the comment body if you don't modify the empty template field, which i think is causing this issue for you. I have fixed it with [47ced2f].
Also if you want to see what go-jira would post without actually posting data, you can use --dryrun --verbose --verbose
which will now print the json data we would have posted, without actually posting the document. It can be helpful to debug stuff like this.
Thanks for the PR, I think you are right in that the overrides got lost when I did some recent refactoring. |
Finally closing this issue/PR, template have been update to use:
|
The default edit template fails when trying examples in the README. Copying the overrides into the opts map ensures that the values specified there are present in the template as .overrides.$name, instead of .overrides.overrides.$name.
I made the comment optional, and added an optional label to the default template, so you can just update a label for an issue if you want.
Another way to accomplish this change would be to just pass the opts["overrides"] to the template instead of the full map. My guess is that was changed at some point when the -m paramater was added. after the docs were written, and everyone has their own custom template files at this point. This seemed less potentially impactful, since the templates may be using values already from opts.