Display commit lists for review requests created with history
Review Request #10094 — Created July 18, 2018 and submitted
The
CommitListField
renders the summaries (and authors if they differ
from the review request submitter) of the commits that make up a
multi-commit review request. This field has been added to a new
ExtraFieldSet
, which exists below theMainFieldSet
. This is due to
theRB.ReviewRequestEditorView
expecting the last field in the main
field set to be an editable text field and working around this
limitation was more complex and convoluted than adding a new fieldset.The JS
RB.ReviewRequestFields.CommitListFieldView
is responsible for
toggling between the full commit message (if it is longer than a single
line) and the summary.
- Ran unit tests.
- Ran JS tests.
- Uploaded review requests with multiple commits and saw the correct
commits displayed in the field and in change descriptions. - Uploaded a plain review request and did not see the new field on
the review request page or change description box.
Description | From | Last Updated |
---|---|---|
Unit tests for the field should probably be added (mentioned as a "TODO" in your Testing Done). Did your test … |
chipx86 | |
E111 indentation is not a multiple of four |
reviewbot | |
E302 expected 2 blank lines, found 1 |
reviewbot | |
F401 'reviewboard.diffviewer.models.DiffCommit' imported but unused |
reviewbot | |
F401 'reviewboard.reviews.builtin_fields.ReviewRequestPageDataMixin' imported but unused |
reviewbot | |
E303 too many blank lines (2) |
reviewbot | |
E702 multiple statements on one line (semicolon) |
reviewbot | |
I'm switching more code over to this (I have a pending change I need to split up and put up … |
chipx86 | |
We do this both here and in should_render(), but we do it differently in each. We should be consistent, or … |
chipx86 | |
Typo: "rquest" -> "request" |
chipx86 | |
Rather than loop through the commits multiple times, how about: include_author_name = not submitter_name should_expand = {} show_expand_collapse = False … |
chipx86 | |
This sounds like a boolean, but it's a dictionary. Maybe call it commits_to_expand? |
chipx86 | |
Let's make this a private method on the class, so it's not redefined every time this method is called. Alternatively, … |
chipx86 | |
The annoyance with {} for both sets and dicts is that this looks pretty weird at first glance. Thinking we … |
chipx86 | |
Missing trailing comma. |
chipx86 | |
We should probably explicitly check that diffset_id is not None here. |
chipx86 | |
Missing a docstring. |
chipx86 | |
Typo: "creatd" -> "created" |
chipx86 | |
We can define this once in the base class instead of in each subclass by doing: if not self.get_review_request().created_with_history: return … |
chipx86 | |
Typo: "creatd" -> "created" |
chipx86 | |
Unwanted blank line. |
chipx86 | |
Alphabetical order. |
chipx86 | |
Can you define a constant for this? |
chipx86 | |
We should either have a constant already for the font size, or you should be able to inherit. |
chipx86 | |
Can you define a constant for this? |
chipx86 | |
We should have constants for this already, since we have the same styling elsewhere. If not, it should be added … |
chipx86 | |
Blank line here. |
chipx86 | |
This is missing the mobile rule in #review-request-main. Really, we should add a mixin that's used both here and there … |
chipx86 | |
Comma before "if any." |
chipx86 | |
Here as well. |
chipx86 | |
Looks like you got some whiteout on your '. |
chipx86 | |
Typo: "statis" -> "status" |
chipx86 | |
Typo: "Collpase" -> "Collapse" |
chipx86 | |
You can do this.$('.commit-message') instead. |
chipx86 | |
Can you start the first parameter on the function call line? That or turn this into a dictionary. Looks a … |
chipx86 | |
Typo: "colum" -> "column" |
chipx86 | |
Instead of - and +, can you use fa fa-plus and fa fa-minus? That's what we use for other collapse/expand … |
chipx86 | |
E501 line too long (83 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
This should be the new full type path. |
chipx86 | |
You should use keyword arguments for these calls to render_to_string(), to ensure compatibility going forward. |
chipx86 | |
Can you put the start of the tuple on the second line? |
chipx86 | |
"Array", not "array". |
chipx86 | |
"Backbone", not "Bckbone". |
chipx86 | |
Alphabetical order. |
chipx86 | |
RequestFactory() should be defined in setUp and not setUpClass, since it keeps state between requests and can introduce subtle failures. |
chipx86 | |
Should be Model Attributes. |
chipx86 | |
Should be jQuery.Event. |
chipx86 | |
Should be jQuery.Event. |
chipx86 | |
Should be jQuery.Event. |
chipx86 | |
Should be boolean. |
chipx86 |
- Summary:
-
WIPDisplay commit lists for review requests created with history
- Description:
-
~ WIP
~ The
CommitListField
renders the summaries (and authors if they differ+ from the review request submitter) of the commits that make up a + multi-commit review request. This field has been added to a new + ExtraFieldSet
, which exists below theMainFieldSet
. This is due to+ the RB.ReviewRequestEditorView
expecting the last field in the main+ field set to be an editable text field and working around this + limitation was more complex and convoluted than adding a new fieldset. + + The JS
RB.ReviewRequestFields.CommitListFieldView
is responsible for+ toggling between the full commit message (if it is longer than a single + line) and the summary. - Testing Done:
-
+ - Ran unit tests.
+ - Uploaded review requests with multiple commits and saw the correct
commits displayed in the field and in change descriptions.
+ - TODO: Add unit tests for the field.
- Depends On:
-
- Commit:
af8a4800e4076aa05c36f4b489023be474aab363bec2c2299fc198e5674b709d1a041b3e0f1064dc- Diff:
Revision 2 (+561 -20)
- Added Files:
- Change Summary:
-
Fix unit test failures and flake8
- Commit:
-
bec2c2299fc198e5674b709d1a041b3e0f1064dc0fd9669d997973173f3add19d431b5ed470c7f14
- Diff:
-
Revision 3 (+584 -20)
- Commit:
-
0fd9669d997973173f3add19d431b5ed470c7f14810ec3a97287d6edd29710bc83454c9da5384edc
- Diff:
-
Revision 4 (+582 -20)
Checks run (2 succeeded)
- Change Summary:
-
Compare stripped commit messages to summaries.
- Commit:
-
810ec3a97287d6edd29710bc83454c9da5384edc43f248095b27f68b24dbab5a85087ec70a00729f
- Diff:
-
Revision 5 (+585 -20)
Checks run (2 succeeded)
- Change Summary:
-
Include expand/collapse column without controls for rows that have summary = commit_message but other rows do not
- Commit:
-
43f248095b27f68b24dbab5a85087ec70a00729fbec8c393e0d8444af1ed55ea03ac1744ea17bcdc
- Diff:
-
Revision 6 (+587 -20)
Checks run (2 succeeded)
- Commit:
-
bec8c393e0d8444af1ed55ea03ac1744ea17bcdc4d5da3f6755a5a57564b6861375f3bb9eb3de6fb
- Diff:
-
Revision 7 (+587 -20)
Checks run (2 succeeded)
-
-
Unit tests for the field should probably be added (mentioned as a "TODO" in your Testing Done).
Did your test run include JavaScript unit tests, and review requests without history support?
-
I'm switching more code over to this (I have a pending change I need to split up and put up for review), but for
render_to_string()
you'll want to use the new compat function we have, which will help us migrate to newer versions of Django soon.from djblets.util.compat.django.template.loader import render_to_string ... render_to_string(template_name=..., context={...}, request=request)
Passing in
request
gives you aRequestContext.
If not passed in, you get aContext
.(It does support passing in those objects themselves, but a dictionary is more future-proof.)
-
We do this both here and in
should_render()
, but we do it differently in each. We should be consistent, or we should have a private helper that wraps it. -
-
Rather than loop through the commits multiple times, how about:
include_author_name = not submitter_name should_expand = {} show_expand_collapse = False for commit in commits: commit_should_expand = (commit.summary.strip() != commit.commit_message.strip()) should_expand[commit.pk] = commit_should_expand if commit_should_expand: show_expand_collapse = True if not include_author_name and commit.author_name != submitter_name: include_author_name = True
Potentially, you could also get rid of
show_expand_collapse
by turningshould_expand
into aset
of ones to expand. It's then easy to check against that for both individual commits and as a larger "are there any commits that should expand". Then we're simply looking at:include_author_name = not submitter_name should_expand = set() for commit in commits: if (commit.summary.strip() != commit.commit_message.strip()): should_expand.add(commit.pk) if not include_author_name and commit.author_name != submitter_name: include_author_name = True
-
-
Let's make this a private method on the class, so it's not redefined every time this method is called.
Alternatively, do this instead:
return { key: set( { 'author': commit.author_name, 'summary': commit.summary, } for commit in commits_by_diffset_id[info[key]] ) for key in ('old', 'new') }
-
The annoyance with
{}
for both sets and dicts is that this looks pretty weird at first glance. Thinking we should useset()
explicitly here to differentiate from the dict. -
-
-
-
-
We can define this once in the base class instead of in each subclass by doing:
if not self.get_review_request().created_with_history: return None if not hasattr(self, '_commit_messages'): self._commit_messages = list( self.get_latest_diffset().commits .values_list('commit_message', flat=True) return self._commit_messages
-
-
-
-
-
-
-
We should have constants for this already, since we have the same styling elsewhere. If not, it should be added and used both here and in the file list.
-
-
This is missing the mobile rule in
#review-request-main
. Really, we should add a mixin that's used both here and there that sets up this styling and the mobile styling. Probably want to sneak in theposition: relative
anddisplay: block
as well, I'd think. -
-
-
-
-
-
-
Can you start the first parameter on the function call line? That or turn this into a dictionary. Looks a bit out of place the way it is.
-
-
Instead of
-
and+
, can you usefa fa-plus
andfa fa-minus
? That's what we use for other collapse/expand controls.
- Change Summary:
-
Addressed chipx86's issues
- Commit:
-
4d5da3f6755a5a57564b6861375f3bb9eb3de6fb3c6cb257bbd6f60e47975c79e703aab80b50f345
- Diff:
-
Revision 8 (+602 -22)
Checks run (2 succeeded)
- Change Summary:
-
Addressed issues.
- Testing Done:
-
- Ran unit tests.
~ - Uploaded review requests with multiple commits and saw the correct
commits displayed in the field and in change descriptions.
~ - TODO: Add unit tests for the field.
~ - Ran JS tests.
~ - Uploaded review requests with multiple commits and saw the correct
commits displayed in the field and in change descriptions.
+ - Uploaded a plain review request and did not see the new field on
the review request page or change description box.
- Commit:
-
3c6cb257bbd6f60e47975c79e703aab80b50f34578a47edf09cf309867f61e51d8b8b24e1ccc1de9
- Diff:
-
Revision 9 (+1208 -22)
- Commit:
-
78a47edf09cf309867f61e51d8b8b24e1ccc1de9f52f4df1c4b4af7da16f3065dbcf2aaa99d98afc
- Diff:
-
Revision 10 (+1210 -22)
Checks run (2 succeeded)
- Change Summary:
-
addressed feedback
- Commit:
-
f52f4df1c4b4af7da16f3065dbcf2aaa99d98afc739f41fc006662013e5d3ebea5250435c00b54af
- Diff:
-
Revision 11 (+1213 -22)
Checks run (2 succeeded)
- Change Summary:
-
addressed feedback
- Commit:
-
739f41fc006662013e5d3ebea5250435c00b54af9d9e132008ca40a3995df51de9f9013114d65d96
- Diff:
-
Revision 12 (+1212 -22)