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

Issue and Pull Request Templates, with addendums #1187

Merged
merged 13 commits into from Aug 21, 2016

Conversation

jez
Copy link
Contributor

@jez jez commented May 30, 2016

This pull request includes all the changes from #1145, including changes
made by @ganmacs and @NickLaMuro, with two small additional fixes on top
of those.

The reviewer is encouraged to see the conversation in #1145.

This pull request itself includes changes that

  • Allow for hub to populate the EDITOR with pull request and issue
    templates
  • Correctly search for such templates, considering things like
    case-insensitivity and file extension. See the GitHub docs for
    more information.
  • Test that the above features work as intended.

Supercedes #1145.
Closes #446, #937, #964, #1118.

ganmacs and others added 11 commits May 30, 2016 12:49
The function of this method is to defer the logic of generating a commit
message to template.go, and eventually remove that logic from
commands/pull_request.go

Also adds tests for this new method, which also modifies the
fixtures/test_repo.go file to accomidate a test repo with a `.github` PR
dir.
This allows the github.GeneratePRTemplate() function to autofill the
pull request title for a single commit pull request with either:

* The entire commit message, if it is a single line commit message
* The first line of the commit message, if it is a multi-line commit
  message

As far as the code is concerned, both cases above are interpreted in the
same fashion, but the expectations of the user are defined with each of
the new test cases in github/template_test.go

FYI, this commit message would be an example of a multi line commit
message :)
Implements the GeneratePRTemplate in pull_request.go instead of the
custom logic that previously existed in the file.  Addresses:

* Title being defaulted as the first line of the template
* Commit messages not defaulting as the title only properly
For the longest time I was assuming that this was a whitespace change
with `git diff`, even though I had fixed it when building this a few
weeks back, so I decided to not bother adding it to the previous
commits.  When I removed it and re-ran the tests, things stopped
working... oops :)
These typos were hiding failing tests (i.e., two mistakes were canelling
each other out and making the tests pass accidentally).

The tests *should* have been failing because the new addGitHubTemplates
function was writing GitHub templates to the wrong place in the test
repo fixture. They need to be written inside the repo, not in the same
directory as the repo.
@jez
Copy link
Contributor Author

jez commented Jun 2, 2016

/cc @mislav Bump :D

message = fmt.Sprintf(message, project.Name)

if template := github.GetIssueTemplate(); template == "" {
message = fmt.Sprintf(message, "", project.Name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this if/else construct is unnecessary. The logic getting executed is identical regardless of the fact whether the template string is empty or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll clean that up.

@mislav
Copy link
Owner

mislav commented Jun 2, 2016

Thanks @jez. This looks good, but I'm still wondering about desired behavior for displaying our usual commented-out text like “# Write a message for this issue. The first line is the title…” I don't think this text should get displayed at all when there is an issue template.

But that opens more questions for to do in the case of PRs. Right now, without a PR template, the text displayed gives you information about which branch is the PR going to get opened against, and provides you with a changelog of all commits (all commented-out). This is useful information. If there is a PR template, we can make all this go away, but that would also eradicate some of this useful information that I just pointed out.

Thoughts?

@jez
Copy link
Contributor Author

jez commented Jun 3, 2016

If there is a PR template, we can make all this go away, but that would also eradicate some of this useful information that I just pointed out.

I've been using my patched fork of hub at work for the past week, and I actually like it the way it is. I frequently write detailed commit messages, and I like how the commits show up so I can copy/paste into my pull request message.

I don't think this text should get displayed at all when there is an issue template.

Even though these are power users (using GitHub, and using the command line, and using configured templates), I think there's value in the user interface aspect of the text. Git has had .gitmessage templates longer than GitHub has had issue templates, and they've never dropped the extra information. There's also no harm to leaving it in, as it gets stripped in the end regardless.

Those are my thoughts on the issue. If you'd like it implemented differently, I'm more than happy to oblige. My core concern is for hub to support templates in the first place, as it's a feature many people will enjoy.

@NickLaMuro
Copy link
Contributor

My 2 cents on the topic (not that I am a heavy code contributor in this endeavour):

I pretty much agree that the change-log of commits, and base and head info should stay in with the template. I found myself referencing that when fleshing out templates myself, and also for double checking that my changes were going to the right spot before I sent it off, and was able to abort by deleting the entirety of the file if that wasn't the case. This info should stay in my humble opinion.

If we were format the comments based on the presence of a template, I think we might want to consider moving the github/template.go code into here:

https://github.com/github/hub/blob/master/commands/pull_request_tpl.go

Or vice versa, as there would need to be a bit of logic mixed with the two when dealing with the rendering of the template and removing certain pieces of text based on whether a template was present or not.

Alternatively, do we treat these like they are already being done with single commit PRs, where a message is pre-filled from the commit message, and that info is displayed as well for that regardless?

I am personally not bothered by being reminded what needs to be done in the Pull Request message, and wouldn't mind leaving it as is. It is also good for people not used to using the pull request templates via hub (or even knew they were a feature of github/hub) to be reminded how it is formatted when editing the template it in your editor. What threw me off the first time I used @ganmacs original implementation was the fact that it put in the template right at the beginning of the buffer, and not until I committed my pull request did I realize that the first line was not the PR title, but the beginning of the template, so everything was formatted weird (hence my infamous "\n\n" in my one-liner!)

P.S. Just noticed that commands/pull_request_tpl.go has a redundant nested {{if .HasCommitLogs}}.

P.P.S @jez Did not know about .gitmessage until you mentioned it, and it is pretty neat, thanks for sharing!

@jez
Copy link
Contributor Author

jez commented Jun 3, 2016

P.S. Just noticed that commands/pull_request_tpl.go has a redundant nested {{if .HasCommitLogs}}.

That's kinda wonky. Fixed.

P.P.S @jez Did not know about .gitmessage until you mentioned it, and it is pretty neat, thanks for sharing!

😀

@jez
Copy link
Contributor Author

jez commented Jun 7, 2016

@mislav I think it's back in your court right now.

@mislav
Copy link
Owner

mislav commented Jun 8, 2016

Thanks for your opinions!

NickLaMuro pushed a commit to NickLaMuro/manageiq that referenced this pull request Jun 9, 2016
This adds a standard way of formatting a pull-request and guiding a contributer
to the prefered format and level of detail for a pull request.  This feature
was recently added to the github web UI:

https://help.github.com/articles/creating-a-pull-request-template-for-your-repository/

And is in the process of being supported in `hub`, the official command line
git augmentation tool for github:

mislav/hub#1187

The idea is this is a suggestion, not an enforcement.  Everything in the quotes
is meant to be a short documentation of guidelines for the commiter to use when
opening a pull-request, and should be deleted and filled out with pull-request
context specific information.  None of the pull-request template is enforced by
github and can be deleted if the commiter so chooses.
@kellyrmilligan
Copy link

would love this as well!!!

@jez
Copy link
Contributor Author

jez commented Jun 14, 2016

Hey @mislav! It's been a little over two weeks now since this PR was opened (and longer if you include the work it builds on). I'd really like to get this merged; is there anything else I can help you with to make merging this easier?

@jez
Copy link
Contributor Author

jez commented Jul 11, 2016

@mislav Bump

@jawshooah
Copy link

If anyone would like to use this patch in the meantime, I've rebased onto 2.2-stable and created a Homebrew Formula in a custom Tap. Feel free to brew install jawshooah/custom/hub

@mislav
Copy link
Owner

mislav commented Aug 12, 2016

@jawshooah Thanks, but this is never going to be 2.2-stable, since it's a big feature change, so having it stay based on master is alright.

Sorry for the wait, everyone! I should be close to pulling this in. I've just released 2.2.4 yesterday and I want 2.3.0 to be the next big feature release.

@NickLaMuro
Copy link
Contributor

NickLaMuro commented Aug 12, 2016

Seems reasonable to me, and been fully satisfied using my hack for months now, so take as much time as you need, at least as far as I am concerned.

@lfilho
Copy link

lfilho commented Aug 13, 2016

I'm eagerly awaiting the official release (automated dotfiles installs,
company's markdown files, etc)

Em sex, 12 de ago de 2016 às 18:14, Nick LaMuro notifications@github.com
escreveu:

Seems reasonable to me, and been full satisfied using my hack
#1145 (comment) for
months now, so take as much time as you need, at least as far as I am
concerned.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#1187 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AARQhOVjE_KLmk-cCbS27cEYSJo02B7bks5qfJvPgaJpZM4IqAb2
.

@ghost
Copy link

ghost commented Aug 18, 2016

@mislav When do you think this will hit a release? Would really like this feature...

@jeroenvisser101
Copy link

@jjeffrey-bolste please see #1232, it's planned for the next big release, and there's also #1187 (comment) from @jawshooah that you can use in the meanwhile :)

@ghost
Copy link

ghost commented Aug 18, 2016

I guess what I was asking is when is that release planned for?

@mislav
Copy link
Owner

mislav commented Aug 19, 2016

I plan to make a prerelease this weekend so people can download a prebuilt binary from the Releases section and try out the new features, including this one!

The actual stable release with all the new features will take a few weeks more, because I'm taking a 2-week vacation starting next week, so I won't be around the work on this project and review PRs during this time.

@mislav mislav merged commit 0de949b into mislav:master Aug 21, 2016
@mislav
Copy link
Owner

mislav commented Aug 21, 2016

Thank you @jez @NickLaMuro @ganmacs @jeroenvisser101 for all the hard work, review, and discussion! This took so long because it was a tricky feature to implement and review, but now it's all done! I'll try to make a prerelease today so people can download and try a precompiled version with the latest features in master, including this one.

@jeroenvisser101
Copy link

Thanks @mislav, appreciate all the effort you put in hub 💯

@NickLaMuro
Copy link
Contributor

\0/

@kellyrmilligan
Copy link

🚀

@mislav
Copy link
Owner

mislav commented Aug 21, 2016

https://github.com/github/hub/releases/tag/v2.3.0-pre3

@jeroenvisser101
Copy link

@mislav did you forget to mention PR templates in the changelog?

@mislav
Copy link
Owner

mislav commented Aug 22, 2016

@jeroenvisser101 No, it's in there. I call them “repo-specific” templates, for lack of a better term.

@jeroenvisser101
Copy link

Ah, I see! :)

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.

Templatize pull-request message/title
8 participants