Fixed the 'X-ReviewBoard-Diff-For' mail header to include modified files.
Review Request #9206 — Created Sept. 22, 2017 and submitted
The email generated after posting a review had an incomplete
'X-ReviewBoard-Diff-For' header. The header appeared for newly created files
and moved files but didn't appear for files that were only modified. The code
that was responsible for adding the header in question was ignoring modified
files. A check for modified files was added to the respective if statements and
a 'modified' attribute was added to the FileDiff class.
Posted reviews for a Tester Repository containing an edited file 'README.md'
and a created file 'FileA' to recreate the bug.Header generated from a posted review with both a created file and an edited
file:X-ReviewBoard-Diff-For: FileA
X-ReviewBoard-Diff-For
only appears for the created file, 'FileA'.After the fix, the same test was performed again with a created file 'FileA'
and an edited file 'README.md'.Header generated from a posted review with an edited file and a created file:
X-ReviewBoard-Diff-For: FileA X-ReviewBoard-Diff-For: README.md
X-ReviewBoard-Diff-For
appears for both 'FileA' and 'README.md'.Ran unit tests.
Description | From | Last Updated |
---|---|---|
The subject could also be improved by using the form: Fixed the X-ReviewBoard-Diff-For mail header to include modified files. This … |
chipx86 | |
Perhaps too much info in Testing Done. It's hard to see the meat of the testing with all the headers. … |
chipx86 | |
Descriptions and Testing Done should wrap at around 70-75 characters. The first line of the description can go away. The … |
chipx86 | |
This change will need unit tests. There's at least one existing test for this header. You should add a test … |
chipx86 | |
E501 line too long (90 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
While the others don't have it, we're trying to introduce docstrings for every new function. These are always in the … |
chipx86 | |
We're now testing every single state except one in these cases. So instead, I'd suggest: if not filediff.is_new: and if … |
chipx86 | |
W293 blank line contains whitespace |
reviewbot | |
These blank lines should be removed. |
chipx86 | |
This isn't quite what we want. The function shouldn't be stating what it's doing internally (that's an implementation detail). Note … |
chipx86 | |
These blank lines should go away. |
chipx86 | |
No blank line. |
chipx86 | |
You can use: self.assertIn('X-ReviewBoard-Diff-For', message.rb_headers) |
chipx86 | |
I'd group the variable with the latter set of assertions, instead of the former. |
chipx86 | |
These should use self.assertIn. |
chipx86 | |
There should only be a single space between words. |
brennie | |
Can you add a comment explaining what this is testing and include the bug number? |
david | |
This should be a comment rather than part of the docstring (since the docstring is used for the test name). |
david | |
Sorry, one more thing. Let's move this into the body of the method, just below the docstring. |
david |
- Description:
-
+ This patch is a response to bug report 4572, on ReviewBoard release 2.0.30.
+ The email generated after posting a review had an incomplete 'X-ReviewBoard-Diff-For' header. The header appeared for newly created files and moved files but didn't appear for files that were only modified. The code that was responsible for adding the header in question was ignoring modified files. A check for modified files was added to the respective if statements and a 'modified' attribute was added to the FileDiff class.
- Testing Done:
-
~ Posted reviews for a Tester Repository containing an edited file 'README.md' and a created file 'FileA' to recreate the bug.
~ Posted reviews for a Tester Repository containing an edited file 'README.md'
+ and a created file 'FileA' to recreate the bug. Header generated from a posted review with both a created file and an edited file:
boundary="===============1791673369560208835=="
MIME-Version: 1.0 Subject: Review Request 2: attempting to recreate bug 4572, through a tester repository From: hmarceau@laurentian.ca To: hmarceau@laurentian.ca Date: Fri, 22 Sep 2017 19:23:45 -0000 Message-ID: 20170922192345.10918.802@hmarceau-VAIO X-ReviewBoard-URL: http://example.com/ Auto-Submitted: auto-generated Sender: hp.marceau@gmail.com X-ReviewGroup: X-Auto-Response-Suppress: DR, RN, OOF, AutoReply X-ReviewRequest-URL: http://example.com/r/2/ X-Sender: hp.marceau@gmail.com X-ReviewBoard-Diff-For: FileA Reply-To: hmarceau@laurentian.ca X-ReviewRequest-Repository: Tester Repository 'X-ReviewBoard-Diff-For' only appears for the created file, 'FileA'.
~ After the fix, the same test was performed again with a created file 'FileA' and an edited file 'README.md'.
~ After the fix, the same test was performed again with a created file 'FileA'
+ and an edited file 'README.md'. Header generated from a posted review with an edited file and a created file:
boundary="===============1047217417420848096=="
MIME-Version: 1.0 Subject: Review Request 3: attempting to recreate bug 4572, through a tester repository From: hmarceau@laurentian.ca To: hmarceau@laurentian.ca Date: Fri, 22 Sep 2017 20:21:20 -0000 Message-ID: 20170922202120.16185.20047@hmarceau-VAIO X-ReviewBoard-URL: http://example.com/ Auto-Submitted: auto-generated Sender: hp.marceau@gmail.com X-ReviewGroup: X-Auto-Response-Suppress: DR, RN, OOF, AutoReply X-ReviewRequest-URL: http://example.com/r/3/ X-Sender: hp.marceau@gmail.com X-ReviewBoard-Diff-For: FileA X-ReviewBoard-Diff-For: README.md Reply-To: hmarceau@laurentian.ca X-ReviewRequest-Repository: Tester Repository --===============1047217417420848096==
MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 'X-ReviewBoard-Diff-For' appears for both 'FileA' and 'README.md'.
- Commit:
-
93fa40f930581aec9530d0c509211931e6221489d4f06682716a71d32d903449511b6d4b8a5485fe
Checks run (2 succeeded)
- Groups:
-
-
Perhaps too much info in Testing Done. It's hard to see the meat of the testing with all the headers. Keep it straightforward and to the point.
I'd also encourage using Markdown constructs more. You can use backticks for things like header names and class names, and triple backticks for blocks of literals like code samples or the blocks of e-mail headers.
-
Descriptions and Testing Done should wrap at around 70-75 characters.
The first line of the description can go away. The bug number should go in the Bugs field, and the Review Board version number (btw, "Review Board" and not "ReviewBoard") should just be a detail on the bug report (as it really applies to both older and newer versions than 2.0.30).
-
This change will need unit tests. There's at least one existing test for this header. You should add a test ensuring that all expected states are handled correctly.
-
While the others don't have it, we're trying to introduce docstrings for every new function. These are always in the form of:
"""One-line summary."""
or:
"""One-line summary. Multi-line description. """
Function docstrings have some additional requirements (which are documented in Notion) but for properties, this is all you need. Search elsewhere in the codebase for
@property
and look for docstrings for examples. -
We're now testing every single state except one in these cases. So instead, I'd suggest:
if not filediff.is_new:
and
if not filediff.deleted:
- Summary:
-
Email header, 'X-ReviewBoard-Diff-For', now appears for Modified Files.Fixed the 'X-ReviewBoard-Diff-For' mail header to include modified files.
- Description:
-
~ This patch is a response to bug report 4572, on ReviewBoard release 2.0.30.
~ ~ The email generated after posting a review had an incomplete 'X-ReviewBoard-Diff-For' header. The header appeared for newly created files and moved files but didn't appear for files that were only modified. The code that was responsible for adding the header in question was ignoring modified files. A check for modified files was added to the respective if statements and a 'modified' attribute was added to the FileDiff class.
~ The email generated after posting a review had an incomplete
~ 'X-ReviewBoard-Diff-For' header. The header appeared for newly created files ~ and moved files but didn't appear for files that were only modified. The code + that was responsible for adding the header in question was ignoring modified + files. A check for modified files was added to the respective if statements and + a 'modified' attribute was added to the FileDiff class. - Testing Done:
-
~ Posted reviews for a Tester Repository containing an edited file 'README.md'
~ Posted reviews for a Tester Repository containing an edited file 'README.md'
and a created file 'FileA' to recreate the bug. ~ Header generated from a posted review with both a created file and an edited file:
~ Header generated from a posted review with both a created file and an edited
+ file: ~ boundary="===============1791673369560208835=="
~ MIME-Version: 1.0 ~ X-ReviewBoard-Diff-For: FileA
~ - Subject: Review Request 2: attempting to recreate bug 4572, - through a tester repository - From: hmarceau@laurentian.ca - To: hmarceau@laurentian.ca - Date: Fri, 22 Sep 2017 19:23:45 -0000 - Message-ID: 20170922192345.10918.802@hmarceau-VAIO - X-ReviewBoard-URL: http://example.com/ - Auto-Submitted: auto-generated - Sender: hp.marceau@gmail.com - X-ReviewGroup: - X-Auto-Response-Suppress: DR, RN, OOF, AutoReply - X-ReviewRequest-URL: http://example.com/r/2/ - X-Sender: hp.marceau@gmail.com - X-ReviewBoard-Diff-For: FileA - Reply-To: hmarceau@laurentian.ca - X-ReviewRequest-Repository: Tester Repository ~ 'X-ReviewBoard-Diff-For' only appears for the created file, 'FileA'.
~ X-ReviewBoard-Diff-For
only appears for the created file, 'FileA'.After the fix, the same test was performed again with a created file 'FileA'
and an edited file 'README.md'. Header generated from a posted review with an edited file and a created file:
~ boundary="===============1047217417420848096=="
~ MIME-Version: 1.0 ~ Subject: Review Request 3: attempting to recreate bug 4572, ~ X-ReviewBoard-Diff-For: FileA
~ X-ReviewBoard-Diff-For: README.md
~ - through a tester repository - From: hmarceau@laurentian.ca - To: hmarceau@laurentian.ca - Date: Fri, 22 Sep 2017 20:21:20 -0000 - Message-ID: 20170922202120.16185.20047@hmarceau-VAIO - X-ReviewBoard-URL: http://example.com/ - Auto-Submitted: auto-generated - Sender: hp.marceau@gmail.com - X-ReviewGroup: - X-Auto-Response-Suppress: DR, RN, OOF, AutoReply - X-ReviewRequest-URL: http://example.com/r/3/ - X-Sender: hp.marceau@gmail.com - X-ReviewBoard-Diff-For: FileA - X-ReviewBoard-Diff-For: README.md - Reply-To: hmarceau@laurentian.ca - X-ReviewRequest-Repository: Tester Repository ~ --===============1047217417420848096==
~ X-ReviewBoard-Diff-For
appears for both 'FileA' and 'README.md'.- MIME-Version: 1.0 - Content-Type: text/plain; charset="utf-8" - Content-Transfer-Encoding: 7bit ~ ~ Ran unit tests.
- - 'X-ReviewBoard-Diff-For' appears for both 'FileA' and 'README.md'.
- Bugs:
-
- Commit:
d4f06682716a71d32d903449511b6d4b8a5485fe9c0e77fbba0f94767e5958c77ba5c4c76034596c- Diff:
Revision 3 (+42 -2)
- Commit:
-
9c0e77fbba0f94767e5958c77ba5c4c76034596c2211b6b6d640ed00293699aa971031b016d02ae1
Checks run (2 succeeded)
-
-
-
This isn't quite what we want. The function shouldn't be stating what it's doing internally (that's an implementation detail). Note how it's just putting the logic of the code into words, which doesn't really help say what the purpose of this function is. It shouldn't even be documented as acting like a function, because as a property it's intended to be more like a value on a class.
Instead, it should say something like: "Whether this file is a modification to an existing file of the same name."
-
-
-
-
-
- Commit:
-
2211b6b6d640ed00293699aa971031b016d02ae1455daa2df8c742bcc3116a6ce0ac4f65a06df5a1
Checks run (2 succeeded)
- Commit:
-
455daa2df8c742bcc3116a6ce0ac4f65a06df5a19777227c45e0975d714957b909580bc07a70f303
Checks run (2 succeeded)
- Commit:
-
9777227c45e0975d714957b909580bc07a70f3031c751a4bccb248b815a98771550f550cca597dfc
Checks run (2 succeeded)
- Commit:
-
1c751a4bccb248b815a98771550f550cca597dfcee87bc0ed35820b2f00833b347cc0c27aeec1aeb