Skip to content
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

Closed
wants to merge 127 commits into from

Conversation

pepin
Copy link

@pepin pepin commented Oct 2, 2015

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.

coryb and others added 30 commits February 10, 2015 16:17
* 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
@@ -52,12 +52,18 @@ comments:
`
const default_edit_template = `# issue: {{ .key }}
update:
{{if .overrides.comment}}
Copy link
Contributor

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 }}

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@coryb
Copy link
Contributor

coryb commented Oct 2, 2015

Thanks for the PR, I think you are right in that the overrides got lost when I did some recent refactoring.

@coryb
Copy link
Contributor

coryb commented Sep 6, 2017

Finally closing this issue/PR, template have been update to use:

summary: >-
   stuff [here]

@coryb coryb closed this Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants