Quality of life fix for rbt post when updating request
Review Request #9442 — Created Dec. 15, 2017 and submitted
The issue: you post a review request with a different set of target
people or groups than are in your .reviewboardrc. When you then update
this existing review request, if you don't re-specify your custom
people/groups, then rbt will overwrite your custom choices with the ones
specified in your .reviewboardrc.With this change, rbt post will use the options in the .reviewboardrc
only when creating a new review request. If you are updating an existing
request, then it will ignore the settings in the .reviewboardrc. You can
still manually change the groups/people in your update if you would
like. Unit tests show this functionality.
Been using this at work successfully.
Manually walked through all the posting options.
Unit tests should cover each case.
Description | From | Last Updated |
---|---|---|
Something went a little weird when posting your latest revision. It looks like you ended up posting the changes only … |
david | |
Should explicitly say "review request" instead of just "request" |
david | |
The loaded config should already exist as self.config |
david | |
Add a blank line between these two. |
david | |
When we do multi-line conditionals, we prefer parens rather than the continuation character: if (self.options.target_groups is None and 'TARGET_GROUPS' in … |
david | |
Add a blank line between these two. |
david | |
Parens here too. |
david | |
This can just be '.reviewboardrc' instead of './.reviewboardrc' That said, do we need to make sure that this is running … |
david | |
In order to avoid leaving the temporary file around in case the test case fails unexpectedly, this should probably be: … |
david | |
Should include the type: args (list): |
david | |
Not all arguments have values. I'd just say that the command line will include each of the items within the … |
david | |
Each of your new test cases needs a docstring in order to print a description when running the test suite. … |
david | |
Add a blank line between these two. |
david | |
Add a blank line between these two. |
david | |
Add a blank line between these two. |
david | |
E501 line too long (83 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
We don't compare booleans against True or False. Instead, this should just do if not self.options.update |
chipx86 | |
Private methods should go at the end of the class. That said, I think this is better as a public … |
chipx86 | |
This can be hard-coded in the open call. |
chipx86 | |
The issue with a chdir is that any command being tested will no longer have access to the source code … |
chipx86 | |
This would be better as: with open(test_file, 'w') as fp: for ...: ... |
chipx86 | |
The file should import six, and then this would be: for key, value in six.iteritems(data): ... |
chipx86 | |
A couple important things to note here: This is assuming only strings are passed as values, which isn't always going … |
chipx86 | |
Is there a reason to flush above and then only close now? I'd suspect we'd want to just close the … |
chipx86 | |
This isn't needed. The rmdir will be sufficient. |
chipx86 | |
This will fail if anything else is written to the directory. We should use shutils.rmtree, and only do this if … |
chipx86 | |
Should be list of unicode. |
chipx86 | |
Docstrings for unit tests shouldn't end in a period. Here and below. |
chipx86 | |
Instead of just having True, can we do use_temp_dir=True? |
david | |
Same here. |
david | |
Same here. |
david | |
Same here. |
david | |
It was like this before, but this return type/description is incorrect. It returns the command instance. |
david |
-
-
-
-
-
When we do multi-line conditionals, we prefer parens rather than the continuation character:
if (self.options.target_groups is None and 'TARGET_GROUPS' in config): ....
-
-
-
This can just be '.reviewboardrc' instead of './.reviewboardrc'
That said, do we need to make sure that this is running within a temporary directory? What is the cwd when these tests run?
-
In order to avoid leaving the temporary file around in case the test case fails unexpectedly, this should probably be:
try: yield finally: tmp.close() os.unlink('.reviewboardrc')
-
-
Not all arguments have values. I'd just say that the command line will include each of the items within the list.
-
Each of your new test cases needs a docstring in order to print a description when running the test suite. See the above tests for examples of what they should look like.
-
-
-
-
Concept behind the change certainly seems reasonable.
I wanted to touch upon the Notion issue. It should be public. What link are you trying? I want to figure out if something regressed.
- Change Summary:
-
flake8
- Commit:
-
4714e99123bf280784c54e947af9be3ecfb91d27119b7173a18da95f35519c7a59aa8f4d537177b2
Checks run (2 succeeded)
- Change Summary:
-
Finally got back to this after the holidays!
Updated chdir to a temp directory to write the mock .reviewboardrc file.
- Commit:
-
119b7173a18da95f35519c7a59aa8f4d537177b28cd45eb7105db136116b70f4f189729d1ea98085
Checks run (2 succeeded)
-
-
Something went a little weird when posting your latest revision. It looks like you ended up posting the changes only in the latest commit and not the full diff between master and your topic branch (probably via something like
rbt post HEAD
). This breaks the interdiffs and doesn't let us userbt land
to land the change. Would you mind re-posting by runningrbt post -r 9442 master..mybranch
?
- Change Summary:
-
Attempting to re-post diff.
Checks run (2 succeeded)
- Change Summary:
-
Another update to try and fix intermediate diffs.
Checks run (2 succeeded)
-
-
We don't compare booleans against
True
orFalse
. Instead, this should just doif not self.options.update
-
Private methods should go at the end of the class. That said, I think this is better as a public function in
RBTestBase
, so that other commands can benefit. I'd call this justreviewboardrc
.This actually should apply to
_create_post_command
as well, even though it wasn't following this rule before.This also needs a docstring.
-
-
The issue with a
chdir
is that any command being tested will no longer have access to the source code repository, if it's testing against one. I'd make the chdir optional. If the unit test is cloning a repository and doing a test in there, it's fine for it to write to that same directory. -
-
-
A couple important things to note here:
- This is assuming only strings are passed as values, which isn't always going to be true. Sometimes it will be booleans or lists.
- It also needs a newline, or multiple values are going to create an invalid file.
Therefore, I'd switch this to:
fp.write('%s = %r\n' % (key, value))
The
%r
will generally return something suitable for the kinds of values we're working with. Down the road, we'll probably need to have a better serializer, but this is fine for now.(We generally use printf-style strings anyway.)
-
Is there a reason to flush above and then only close now? I'd suspect we'd want to just close the file above (which my
with
suggestion will do). -
-
This will fail if anything else is written to the directory. We should use
shutils.rmtree
, and only do this if that optional parameter I mentioned is provided. -
-
- Change Summary:
-
Updated with new review comments.
- Description:
-
- I can't actually access the contributor guide so apologies if I'm missing something. Apparently I need to be granted access to the Notion Wiki? But it doesn't give me anyone to contact.
- - - The issue: you post a review request with a different set of target
people or groups than are in your .reviewboardrc. When you then update this existing review request, if you don't re-specify your custom people/groups, then rbt will overwrite your custom choices with the ones specified in your .reviewboardrc. With this change, rbt post will use the options in the .reviewboardrc
only when creating a new review request. If you are updating an existing request, then it will ignore the settings in the .reviewboardrc. You can still manually change the groups/people in your update if you would like. Unit tests show this functionality. - Commit:
-
8cd45eb7105db136116b70f4f189729d1ea9808520ee4deedd2b4dbd6f82e3a982a5cf92c59b6465
Checks run (2 succeeded)
- Commit:
-
20ee4deedd2b4dbd6f82e3a982a5cf92c59b64659a3d7c838537c6e4a42442334bb87135fa7eff55