Make rbt setup-repo more clear
Review Request #10894 — Created Feb. 7, 2020 and submitted
This change makes the setup-repo command easier to follow and understand
by adding more information concerning the purpose of the command, how to
configure repositories, and the overall status of the config file
creation process.The repository selection process has been simplified;
multiple repositories can be seen at once, and the repository of choice
can simply be selected without having to go through other repositories.Unit tests have also been added for the setup-repo command to ensure
functionality in future releases.I have detailed notes on my current changes here.
Test cases run on python 2.7.17 and 3.7.6:
- Test case validating repository prompt if repositories exist
- Test case validating repository prompt if no repositories exist
- Test case validating config file generation
- Test case validating the contents of config file
- Test case validating server options
- Test case validating perforce options
- Test case validating tfs options
Description | From | Last Updated |
---|---|---|
E127 continuation line over-indented for visual indent |
reviewbot | |
E126 continuation line over-indented for hanging indent |
reviewbot | |
W391 blank line at end of file |
reviewbot | |
oops forgot to include this in the other review but did you mean to include this in the RB? correct … |
hxqlin | |
i think you can combine line 33 and line 34 |
hxqlin | |
wouldn't closest_path be better named as closest_paths? to make it clear it's multiple "closest paths" and not just one |
hxqlin | |
do you need both of tool_name and closest_path? it looks like you're only using tool_name in the string you're passing … |
hxqlin | |
i think 'path'])) should be on the previous line |
hxqlin | |
i'm a little confused about the logic here - so i think you're waiting for a RB server URL to … |
hxqlin | |
typo - double a |
hxqlin | |
is there any particular reason why you used separate print statements here as opposed to a single print with a … |
hxqlin | |
if closest_path is a list, wouldn't it make more sense to name it closest_paths instead? to make it clear it's … |
hxqlin | |
i think this could be better described as A list of best-matching repositories from a valid Review Board server. - … |
hxqlin | |
i think the comment could be clearer if it said something like A dictionary containing repository metadata. |
hxqlin | |
is fields a dictionary? or a list? the list of unicode and rest of the comment seem to contradict one … |
hxqlin | |
i think this extra line needs to be kept |
hxqlin | |
i think this needs to be reverted |
hxqlin | |
i think it would be better to use answers instead of values here - it wasn't clear to me whether … |
hxqlin | |
i think this could be clearer - it sounds like the user has to pick a list as a response … |
hxqlin | |
maybe this line could be replaced by raise ValueError? so that the catch block will be the only place you … |
hxqlin | |
E501 line too long (80 > 79 characters) |
reviewbot | |
F821 undefined name 'request_id' |
reviewbot | |
E501 line too long (80 > 79 characters) |
reviewbot | |
E501 line too long (82 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
E501 line too long (83 > 79 characters) |
reviewbot | |
E501 line too long (104 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
E501 line too long (85 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
not really familiar with .rst but i'm not understanding how .. _configuring: turned into Usage $ rbt setup-repo [options] in … |
hxqlin | |
This spacing is a lil weird - could we get them to line up like before? |
hxqlin | |
same comment as above about getting these line lengths to line up a bit better |
hxqlin | |
I think 'rbt --help setup-repo' and 'https://www.reviewboard.org/docs/' could be inlined as opposed to using string format (the %s) since they're … |
hxqlin | |
Could do for current_index in range(len(closest_paths)) instead as 0 is a default start parameter for range |
bui1 | |
The 1st line of the file says """Test for RBTools setup-repo command.""" but this line has Tests. Make it consistent … |
bui1 | |
I think you can remove the if |
hxqlin | |
Each of these docstrings needs a period at the end |
bui1 | |
Could we seperate the contents of the unit test with a new line? That way it'd be like, where we … |
bui1 | |
I'm not quite sure on the style rules for these tests but could we get some more whitespace in here … |
hxqlin | |
same comment about removing if - same goes for below tests |
hxqlin | |
E501 line too long (104 > 79 characters) |
reviewbot | |
could use self.assertNone instead |
bui1 | |
could use self.assertTrue here |
bui1 | |
Can use self.assertFalse here |
bui1 | |
could use self.assertTrue here |
bui1 | |
could use self.assertTrue here |
bui1 | |
I think there's a typo in peforce - should be Perforce right? (not sure if the capitalization is needed but … |
hxqlin | |
is this class providing something like a mock endpoint from which to retrieve repository URLs from? i'm not super clear … |
hxqlin | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
Missing docstring |
hxqlin | |
E501 line too long (85 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
Rewording this line could help bring clarity more of that this function does. I think changing it to Accepted answers … |
bui1 | |
E501 line too long (104 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
E501 line too long (85 > 79 characters) |
reviewbot | |
E501 line too long (89 > 79 characters) |
reviewbot | |
E501 line too long (99 > 79 characters) |
reviewbot | |
These labels are global throughout the entire docs, so we should be a bit more specific in the name here. |
david | |
One blank line between the header and the text please. Here and below. |
david | |
We can link to the relevant docs in the Review Board manual with :ref:rb:repositories |
david | |
Let's add two blank lines above each of these sections. |
david | |
Can we add a docstring for this please? |
david | |
This can go on the previous line. |
david | |
Please add a blank line above this one. |
david | |
It's usually not great to put exclamation points in output text. |
david | |
I'm not pleased with all of these print statements which start with a newline. Perhaps we can add the extra … |
david | |
I know other comments in here aren't all correct, but new ones should be in the imperative mood rather than … |
david | |
One space between the arg name and type, colon at the end. |
david | |
Indent this 4 more spaces. |
david | |
One space between the arg name and type, colon at the end. |
david | |
Indent this four more spaces. |
david | |
Instead of defining self._mock_input, you should be able to just use: self.spy_on(get_input, call_fake=lambda: '1') |
david | |
The way this is wrapped is confusing (it wraps in the middle of inner parens, making it unclear that path= … |
david | |
Same here re: wrapping. |
david | |
unicode shouldn't be capitalized here. But if you eliminate this function entirely it doesn't matter :) |
david | |
Please add a module docstring for this file. |
david | |
This needs a docstring. |
david | |
Wrapping is a little funky here. |
david | |
Indent this 4 more spaces. |
david | |
This should include a "Returns:" section. |
david | |
This should include a "Returns:" section. |
david | |
The python type is named "int" |
david | |
Please add a blank line between these two. |
david | |
I feel like we probably want to return int_answer here. The place which uses this immediately converts to int again. |
david | |
Please add a blank line above this. |
david | |
E128 continuation line under-indented for visual indent |
reviewbot | |
I think we should probably make it more clear that this first sentence is only for RBCommons subscribers. For folks … |
mike_conley | |
Looking around at the other commands, I think we tend to use print() in place of inserting \n characters. Example: … |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
If possible, let's try to be consistent about where we put spaces at line breaks. I believe the convention in … |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
Same as above, re: \n characters. |
mike_conley | |
So if they say no, do we just ask again? Remind me again - was it a conscious choice on … |
mike_conley | |
Small nit, but let's have two blank lines here. We usually use 2 between sections, and the .. rbt-command-usage:: directive … |
chipx86 | |
Let's define a reference for RBCommons, and then use RBCommons_ everywhere we reference it, so that it'll link. The reference … |
chipx86 | |
"here" is almost always a bad choice for a label for an anchor, because screen readers can't really present that … |
chipx86 | |
We can use :ref:rbtools-reviewboardrc to reference .reviewboardrc. It will have the right name, and it will link to the documentation … |
chipx86 | |
We can nuke this last sentence if we have set up the links above properly. |
chipx86 | |
Let's do two blank lines here. |
chipx86 | |
Keys should all be in alphabetical order. Same with ones below. |
chipx86 | |
This is missing a trailing comma. |
chipx86 | |
This is missing a trailing comma. |
chipx86 | |
We didn't have this before, but can you have a blank line between each variable definition? Helps to keep them … |
chipx86 | |
This should be an absolute path. |
chipx86 | |
Missing a trailing comma. |
chipx86 | |
There's a tweak to this that I'd like to see. It was what I had in my head when we … |
chipx86 | |
This would be a little more clear as: """Initialize the base functionality for the command. |
chipx86 | |
This must use the absolute path to the type, so rbtools.api.transport.Transport. It must also have , optional after the type, … |
chipx86 | |
I'd suggest just: The transport class used for all API communication. By default, this uses the transport defined in :py:attr:`default_transport_cls`. … |
chipx86 | |
After the above changes, this would be self.transport_cls. |
chipx86 | |
The % should be on the last line. |
chipx86 | |
We're eventually going to want to localize our code, and we can get a head start by using a different … |
chipx86 | |
Looking through some of the other RBTools files, I think the convention for formatting here is: printf('Some formatted string: %s, … |
mike_conley | |
Blank line between these. |
chipx86 | |
Blank line here (the return is the conclusion, and not part of the outputting block of code, so it gets … |
chipx86 | |
There's a lot of strings like these that are going to be pretty long, and they might not look good … |
chipx86 | |
The % CONFIG_FILE should go on its own line. |
chipx86 | |
Comments should use proper sentence structure (capitalization, punctuation, "the", etc.). |
chipx86 | |
"URL" "neither api_root nor ..." |
chipx86 | |
"repository" instead of "repo". Helps in comments for those still learning terminology/code. |
chipx86 | |
You'll need to test this part a bit more, because it will break. When passing multiple values to %, you … |
chipx86 | |
Can you use backticks around the rbt --help setup-repo? Maybe even just do rbt help setup-repo, to keep it a … |
chipx86 | |
This should be formatted like: question = ( '.......' % (outfile_path, output) ) |
chipx86 | |
When you have code that needs to iterate through something and return both an index and a value, it's best … |
chipx86 | |
Can we use %d instead of %i? There isn't much of a difference, but we've standardized on %d, and consistency … |
chipx86 | |
Just like above, let's prepare for localization and use %(blah)s arguments and a dictionary. |
chipx86 | |
For os-level commands, we prefer to import os and then reference as os.path, etc. This avoids common problems with redefining … |
chipx86 | |
These aren't needed, since you're not doing anything other than calling the parent. |
chipx86 | |
It's best to group things into paragraphs, to avoid code just all blurring together. Spying on functions is a paragraph. … |
chipx86 | |
Can you call this using keyword arguments, to help with readability and future potential changes? Same below. |
chipx86 | |
You can use assertIsInstance. |
chipx86 | |
fp is commonly used for with open(...), and thus will be a little more familiar and readable. |
chipx86 | |
It's best to format these things like: self.assertEqual( config_lines, [ '...', '...', '...', ]) Helps break them apart, keep them … |
chipx86 | |
Missing a trailing comma. |
chipx86 | |
Let's pull out setup.options into a variable, so we can condense all this, reduce the noise. Same with other tests. |
chipx86 | |
+= is actually a little faster than .extend (operators generate different opcodes and are invoked in different ways than function … |
chipx86 | |
Blank line between class docstrings and members. |
chipx86 | |
Missing docs for *args and **kwargs. |
chipx86 | |
Missing , optional. |
chipx86 | |
When referencing classes, we use: :py:class:`absolute.path.to.Class` For modules, use :py:mod:. |
chipx86 | |
Missing , optional. |
chipx86 | |
Same notes as above. |
chipx86 | |
We shouldn't use backticks in the summary. It can turn out wonky. We also really want to describe here what … |
chipx86 | |
These should use :py:class: to reference these classes. |
chipx86 | |
When referencing an attribute on the class, use: :py:attr:`list_payload` |
chipx86 | |
Missing docs for *args and **kwargs. |
chipx86 | |
Should use :py:class:. |
chipx86 | |
This must be an absolute class path. |
chipx86 | |
API requests always use absolute URLs. |
chipx86 | |
Blank line between these. |
chipx86 | |
Same comments as above. Also, there's some leading whitespace here. |
chipx86 | |
Use :py:meth: to reference methods. Same comments otherwise apply to these docs. |
chipx86 | |
This should be an absolute path. |
chipx86 | |
This can be one statement. |
chipx86 | |
No blank line here. |
chipx86 | |
E126 continuation line over-indented for hanging indent |
reviewbot |
- Change Summary:
-
Updated description to be less than 80 characters long
- Description:
-
Not ready for review!
~ This is a fix to make the purpose of
rbt setup-repo
command easier to understand.~ The instructions, errors, and other relevant outputs will simply be updated. ~ This is a fix to make the purpose of
rbt setup-repo
command easier to~ understand. The instructions, errors, and other relevant outputs will + simply be updated. ~ As an addition, adding unit tests for
setup-repo
is currently in my roadmap for this project.~ As an addition, adding unit tests for
setup-repo
is currently in my+ roadmap for this project. I have notes on my current changes here.
- Branch:
-
release-2.0.xsetup-repo-fix
- Commit:
-
79c30c7acfb24eeb33f51c43ecc10096cd8ac3d17e38198b2eca4fac292015e6633ced68c83c35d0
Checks run (1 failed, 1 succeeded)
flake8
- Change Summary:
-
Updated tests - some still TODO
- Commit:
-
7e38198b2eca4fac292015e6633ced68c83c35d09ac4312f3ec3aa29748f38418461ed602fbc344d
Checks run (2 succeeded)
- Change Summary:
-
Updated repo prompt and descriptions + added tests
- Summary:
-
[WIP] Make rbt setup-repo more clearMake rbt setup-repo more clear
- Description:
-
~ Not ready for review!
~ This change makes the setup-repo command easier to follow and understand
+ by adding more information concerning the purpose of the command, how to + configure repositories, and the overall status of the config file + creation process. ~ This is a fix to make the purpose of
rbt setup-repo
command easier to~ understand. The instructions, errors, and other relevant outputs will ~ simply be updated. ~ The repository selection process has been simplified;
~ multiple repositories can be seen at once, and the repository of choice ~ can simply be selected without having to go through other repositories. ~ As an addition, adding unit tests for
setup-repo
is currently in my~ roadmap for this project. ~ Unit tests have also been added for the setup-repo command to ensure
~ functionality in future releases. ~ I have notes on my current changes here.
~ I have detailed notes on my current changes here.
- Testing Done:
-
+ Test cases run on python 2.7.17 and 3.7.6:
+ - Test case validating config file generation + - Test case validating the contents of config file + - Test case validating server options + - Test case validating peforce options + - Test case validating tfs options - Commit:
-
9ac4312f3ec3aa29748f38418461ed602fbc344d9eee524a588a303f8527c4edd988f728c132ff8d
- Diff:
-
Revision 4 (+264 -45)
- Removed Files:
- Added Files:
- Change Summary:
-
Addressed linter issues
- Commit:
-
9eee524a588a303f8527c4edd988f728c132ff8d70b0215cf8205574f5ebd0d51212f4ace01db2b8
Checks run (2 succeeded)
- Change Summary:
-
Updated server URL prompt to remove confirmation + uploaded image of URL prompt
- Commit:
-
70b0215cf8205574f5ebd0d51212f4ace01db2b82e2da9d9b53ebdf76be629ef7cb0c361f30e21bf
- Diff:
-
Revision 6 (+277 -47)
- Added Files:
Checks run (2 succeeded)
-
-
looking good! i have a comment about the screenshots - i'm not sure if there's a direct link between the before/afters but if there is, it would be helpful if you could name them consistently so it's easier to compare the before and after. for example, if you have a screenshot called
Before: no repo found or selected
it would be a lot easier to compare the after screenshot if it was namedAfter: no repo found or selected
-
-
wouldn't
closest_path
be better named asclosest_paths
? to make it clear it's multiple "closest paths" and not just one -
do you need both of
tool_name
andclosest_path
? it looks like you're only usingtool_name
in the string you're passing toconfirm_select
-
-
i'm a little confused about the logic here - so i think you're waiting for a RB server URL to be entered and you validate it inside the loop. once you validate it, it looks like you're checking whether
api_root
andapi_client
exist again on line 142 and retrieving it if they don't. does it need to be checked twice? -
-
is there any particular reason why you used separate
print
statements here as opposed to a singleprint
with a long string like on line 115? if we do need separateprint
statements here, is it possible to move line 159 and line 168 to the previous lines so that the formatting is consistent? -
if
closest_path
is a list, wouldn't it make more sense to name itclosest_paths
instead? to make it clear it's plural and not just a single path -
i think this could be better described as
A list of best-matching repositories from a valid Review Board server.
- the current comment sounds likeclosest_path
is an object that contains a list of unicode -
i think the comment could be clearer if it said something like
A dictionary containing repository metadata.
-
is fields a dictionary? or a list? the
list of unicode
and rest of the comment seem to contradict one another -
-
-
i think it would be better to use
answers
instead ofvalues
here - it wasn't clear to me whethervalues
was referring to parameters of the function or the answers -
i think this could be clearer - it sounds like the user has to pick a list as a response and not just one of the options. maybe something like
The list of available options that the user can choose a response from.
-
maybe this line could be replaced by
raise ValueError
? so that the catch block will be the only place you need to print this string
- Change Summary:
-
Addressed Hannah's comments and suggestions.
- Branch:
-
setup-repo-fixmaster
- Commit:
-
2e2da9d9b53ebdf76be629ef7cb0c361f30e21bf795e8cb534b61da9c148a40cc80e9c5e6cbc67c2
Checks run (2 succeeded)
- Change Summary:
-
Removed exit from prompt + reverted config file to try fix issues with patch changes appearing in revision?
- Branch:
-
mastersetup-repo-fix
- Commit:
-
795e8cb534b61da9c148a40cc80e9c5e6cbc67c21836c100e5c368a1a394355ed0524f8a7099e2a1
- Change Summary:
-
Pulled latest release-2.0.x changes
- Commit:
-
1836c100e5c368a1a394355ed0524f8a7099e2a1ecbaf775cd180c11f4fc192f4e495b0a14627d4a
Checks run (2 succeeded)
- Change Summary:
-
Updated some photos
-
old_repo_not_confirmed.png: Before: inputing No for a repoBefore: select but decline a repo - Removed Files:
- Added Files:
-
no_server_no_exit.png: New:starting command without a server specifiedAfter: starting command without a server specified
- Change Summary:
-
Used cherry-pick + rebase interactive to fix issues with overwritten config file
- Branch:
-
setup-repo-fixrelease-2.0.x
- Commit:
-
ecbaf775cd180c11f4fc192f4e495b0a14627d4a480fd198c566a316b4eb36007e04af2d3a113e7a
Checks run (2 succeeded)
- Change Summary:
-
Rebased latest changes from release-2.0.x branch
- Commit:
-
480fd198c566a316b4eb36007e04af2d3a113e7ab224dcb6a8343894f3474c7f1dfecd00e0c78b0b
Checks run (2 succeeded)
- Change Summary:
-
Updated descriptions to be shorter + setup-repo docs + minor comment styling
- Commit:
-
b224dcb6a8343894f3474c7f1dfecd00e0c78b0b928aff8ea165c0033cb3e9275e692d04a7bce622
- Diff:
-
Revision 12 (+307 -48)
- Removed Files:
- Added Files:
Checks run (2 succeeded)
- Change Summary:
-
Added one more unit test
- Commit:
-
928aff8ea165c0033cb3e9275e692d04a7bce622f97923ea194e5f041c7632ed00947aa3f1854f5a
Checks run (1 failed, 1 succeeded)
flake8
- Change Summary:
-
Minor syntax change + updated commit message
- Testing Done:
-
Test cases run on python 2.7.17 and 3.7.6:
+ - Test case validating repository prompt if repositories exist + - Test case validating repository prompt if no repositories exist - Test case validating config file generation - Test case validating the contents of config file - Test case validating server options - Test case validating peforce options - Test case validating tfs options - Commit:
-
f97923ea194e5f041c7632ed00947aa3f1854f5a3a3894253da90804e714d1ef78531b4d3ac94fbe
Checks run (1 failed, 1 succeeded)
flake8
- Change Summary:
-
Some whitespace changes to a print statement
- Commit:
-
3a3894253da90804e714d1ef78531b4d3ac94fbe64a71292f04fb0a5748f4d48cb0fcd2f3cdf18f9
Checks run (1 failed, 1 succeeded)
flake8
-
-
not really familiar with
.rst
but i'm not understanding how.. _configuring:
turned intoUsage $ rbt setup-repo [options]
in the screenshot (captioned "After: setup-repo documentation") could you explain that?
-
-
-
I think
'rbt --help setup-repo'
and'https://www.reviewboard.org/docs/'
could be inlined as opposed to using string format (the %s) since they're constants -
-
-
I'm not quite sure on the style rules for these tests but could we get some more whitespace in here if that's allowed? I feel like it's a bit hard to read when it's in a big block like this - same goes for the other tests
-
-
I think there's a typo in
peforce
- should bePerforce
right? (not sure if the capitalization is needed but pretty sure there's an 'r' in there :P) -
is this class providing something like a mock endpoint from which to retrieve repository URLs from? i'm not super clear on what it's doing. also, i don't think the methods
execute_request_method
andget_url
are used anywhere -
-
Just a couple minor things to address! Overall the content of the change is pretty solid :)
-
Could do
for current_index in range(len(closest_paths))
instead as 0 is a default start parameter for range -
The 1st line of the file says
"""Test for RBTools setup-repo command."""
but this line hasTests
. Make it consistent usingTests
-
-
Could we seperate the contents of the unit test with a new line?
That way it'd be like, where we setup our test, then call the function, then assert the results. It makes it easier to scan what's happening
setup = self._create_setup_repo_command() self.spy_on(get_input, call_fake=self._mock_input) self.spy_on(confirm_select) self.spy_on(setup._display_rb_repositories) setup.default_transport_cls = TestTransport('testmockurl') mock_api_root = setup.default_transport_cls.get_root() output = setup.prompt_rb_repository('Git', RepositoryInfo( path='testpath'), mock_api_root) self.assertTrue(setup._display_rb_repositories.called) self.assertTrue(isinstance(output, ItemResource))
-
-
-
-
-
-
Rewording this line could help bring clarity more of that this function does.
I think changing it to
Accepted answers are integers starting from 1 until an integer n representing the nth element within options.
should help
- Change Summary:
-
Addressed linting issues from flake8
- Commit:
-
64a71292f04fb0a5748f4d48cb0fcd2f3cdf18f9f83e8f2e41353f61d441f8b0bcff9806ecbe54b5
Checks run (2 succeeded)
- Change Summary:
-
Addressed several reviewer suggestions and comments
- Commit:
-
f83e8f2e41353f61d441f8b0bcff9806ecbe54b59481e9ab54884d89f0239da2e60ddfc900620668
Checks run (2 succeeded)
- Change Summary:
-
Improved docstrings for TestTransport class
- Commit:
-
9481e9ab54884d89f0239da2e60ddfc900620668b9f8adbacbc18d9c314705e40b935e82bef57bb8
Checks run (2 succeeded)
-
By and large the functionality here looks great. Most of these are pretty simple cleanup and style comments.
-
These labels are global throughout the entire docs, so we should be a bit more specific in the name here.
-
-
-
-
-
-
-
-
I'm not pleased with all of these print statements which start with a newline. Perhaps we can add the extra newline to the end of the previous print statements? It would maybe result in an extra blank line at the end of the output, but that's probably fine.
Alternatively, having two print statements is much prettier to look at:
```python
print()
print('No %s repository found for ...') -
I know other comments in here aren't all correct, but new ones should be in the imperative mood rather than passive ("Display all" instead of "Displays all")
-
-
-
-
-
Instead of defining
self._mock_input
, you should be able to just use:self.spy_on(get_input, call_fake=lambda: '1')
-
The way this is wrapped is confusing (it wraps in the middle of inner parens, making it unclear that
path=
is an arg toRepositoryInfo
instead ofprompt_rb_repository
). How about:output = setup.prompt_rb_repository( 'Git', RepositoryInfo(path='testpath'), mock_api_root)
You could also put each arg on its own line if you like.
-
-
unicode
shouldn't be capitalized here. But if you eliminate this function entirely it doesn't matter :) -
-
-
-
-
-
-
-
-
I feel like we probably want to return
int_answer
here. The place which uses this immediately converts toint
again. -
- Change Summary:
-
Addressed David's review
- Testing Done:
-
Test cases run on python 2.7.17 and 3.7.6:
- Test case validating repository prompt if repositories exist - Test case validating repository prompt if no repositories exist - Test case validating config file generation - Test case validating the contents of config file - Test case validating server options ~ - Test case validating peforce options ~ - Test case validating perforce options - Test case validating tfs options - Commit:
-
b9f8adbacbc18d9c314705e40b935e82bef57bb826e0420e5252081f84f20f2af8b58084f59f3668
- Change Summary:
-
Fixed minor linting issue that I forgot to properly address
- Commit:
-
26e0420e5252081f84f20f2af8b58084f59f36681c16e3dbda24a271f944d7a0b45c356b960c8790
Checks run (2 succeeded)
-
This looks great, Katherine! Just a few cosmetic notes and questions.
-
I think we should probably make it more clear that this first sentence is only for RBCommons subscribers. For folks doing their own deployments (who might not know what RBCommons is), this might be a little confusing.
Perhaps:
If you are an RBCommons customer, you can add repositories under your team administration settings. If you are managing your own deployment of Review Board, refer to the Admin Dashboard. See :ref:`here <rb:repositories>` for more information.
-
Looking around at the other commands, I think we tend to use
print()
in place of inserting\n
characters. Example: https://github.com/reviewboard/rbtools/blob/85534a29cf9d7e7b0defdf1ba6817dc6c71491e3/rbtools/commands/info.py#L62 -
-
-
If possible, let's try to be consistent about where we put spaces at line breaks. I believe the convention in
rbtools
is to put the space at the end of the line rather than the beginning. -
-
-
-
-
-
So if they say no, do we just ask again? Remind me again - was it a conscious choice on our part not to exit if they said "no"?
- Change Summary:
-
Made some changes to address Mike's review
- Commit:
-
1c16e3dbda24a271f944d7a0b45c356b960c87901dfa422e8b22332738cfd3d124e977c7cecbf176
- Diff:
-
Revision 21 (+537 -507)
Checks run (2 succeeded)
- Change Summary:
-
Updated current branch to stay updated with release-2.0.x branch
- Commit:
-
1dfa422e8b22332738cfd3d124e977c7cecbf17642072011b40f2fc773e72a6e8b72ea6d3f4cefa4
Checks run (2 succeeded)
-
I'm really happy with this - great job, Katherine! I just have one last question related to how some of these
print
statements are formatted. -
Looking through some of the other RBTools files, I think the convention for formatting here is:
printf('Some formatted string: %s, %s, %s' % (list, of, variables))
Or was the linter bugging you about this?
-
Hey, this is great!!
Don't be scared by the number of comments here. It's mostly tiny syntactical nits, and I repeat them where I see them. You'll be able to knock them off quickly.
Most of this is actually doc-related, just trying to get the docs to conform to our standards a bit better (using ReStructuredText role indicators to reference classes/methods/attributes/modules, pointing out missing docs, tweaks to wording, etc.).
The core of this is great and I cannot wait to get this in (I just used the current
setup-repo
last night for a new repository and immediately wished I was running this code). -
Small nit, but let's have two blank lines here. We usually use 2 between sections, and the
.. rbt-command-usage::
directive is basically its own section.We do collapse that down if we have multiple directives in a row, but when we're in a situation like this, it helps to distinguish the directive from an anchor (the
.. _blah:
). -
Let's define a reference for RBCommons, and then use
RBCommons_
everywhere we reference it, so that it'll link.The reference can be at the bottom of the file:
.. _RBCommons: https://rbcommons.com/
-
"here" is almost always a bad choice for a label for an anchor, because screen readers can't really present that in any meaningful way.
Instead, let's do:
:ref:`Learn more about configuring repositories <rb:repositories>`.
-
We can use :ref:
rbtools-reviewboardrc
to reference.reviewboardrc
. It will have the right name, and it will link to the documentation on the file. (This is fairly new.)Let's also reference the
REVIEWBOARD_URL
item directly. You'd need to create an anchor for it inrbt/configuration/repositories.rst
, but it'll help. -
-
-
-
-
-
We didn't have this before, but can you have a blank line between each variable definition? Helps to keep them visually distinct.
-
-
-
There's a tweak to this that I'd like to see. It was what I had in my head when we first discussed this on Slack, but I'm not sure I covered the use case well enough.
In your current implementation,
default_transport_cls
is assigned during initialization. What I had intended was for this to be a class-level attribute, like:default_transport_cls = SyncTransport
(Documented using our standard class attribute documenting conventions, using
#:
syntax.)That's the default one for the class, which can be overridden during initialization.
__init__
would takeNone
as its default value. The body would then be:self.transport_cls = transport_cls or self.default_transport_cls
This gives us some advantages:
- A command can easily customize its default transport, and subclasses can benefit from that default as well, without mucking about with passing things in
__init__
. - The transport for a class can be introspected or even replaced (during testing) without first instantiating the class (useful for some categories of tests).
- When initializing, we can still override for that specific instance.
- A command can easily customize its default transport, and subclasses can benefit from that default as well, without mucking about with passing things in
-
-
This must use the absolute path to the type, so
rbtools.api.transport.Transport
.It must also have
, optional
after the type, since it's not required. -
I'd suggest just:
The transport class used for all API communication. By default, this uses the transport defined in :py:attr:`default_transport_cls`.
The current description is describing mostly what happens to this. We want to focus more on what this is for.
-
-
-
We're eventually going to want to localize our code, and we can get a head start by using a different format for placeholders in format strings:
print( '%(num)s %(repo_type)s repositories found:' % { 'num': len(closest_paths), 'repo_type': tool_name, })
The reason for this is that, when you localize, you may end up with a sentence that requires changes in the order of replaced values. So maybe the number comes after the type name. We can't make this happen if we're using just
%s
or similar, but we can if they're named.Same sort of thing in strings below.
-
-
Blank line here (the
return
is the conclusion, and not part of the outputting block of code, so it gets its own paragraph). -
There's a lot of strings like these that are going to be pretty long, and they might not look good on all terminals. Terminals will wrap at the boundary, even if it breaks a word, so we need to do better.
Long-term plan is to replace
print()
with something that will handle this for us, but short-term, you can do:print(textwrap.fill('.....'))
This will wrap at 70 characters, which is safe for most terminals, and will be safe for future localization.
-
-
-
-
-
You'll need to test this part a bit more, because it will break. When passing multiple values to
%
, you need to provide a tuple. What you're actually providing here is 1 formatting value, and a new argument toprint()
. -
Can you use backticks around the
rbt --help setup-repo
?Maybe even just do
rbt help setup-repo
, to keep it a little cleaner. -
-
When you have code that needs to iterate through something and return both an index and a value, it's best to use
enumerate
, like so:for i, repo_name in enumerate(closest_paths): print(....)
-
Can we use
%d
instead of%i
? There isn't much of a difference, but we've standardized on%d
, and consistency is good. -
-
For
os
-level commands, we prefer toimport os
and then reference asos.path
, etc.This avoids common problems with redefining something like
path
, and provides contexts to the calls. -
-
It's best to group things into paragraphs, to avoid code just all blurring together.
Spying on functions is a paragraph. We can describe it as something distinct from setting up the command, or setting up state, or invoking behavior, or asserting results. These are all paragraphs.
You can apply those to tests below.
-
Can you call this using keyword arguments, to help with readability and future potential changes?
Same below.
-
-
-
It's best to format these things like:
self.assertEqual( config_lines, [ '...', '...', '...', ])
Helps break them apart, keep them maintainable. Easier to add new items without worrying about re-wrapping later.
-
-
Let's pull out
setup.options
into a variable, so we can condense all this, reduce the noise.Same with other tests.
-
+=
is actually a little faster than.extend
(operators generate different opcodes and are invoked in different ways than function calls).This isn't performance-critical code, so it doesn't actually matter, but we use it for consistency now.
-
-
-
-
-
-
-
We shouldn't use backticks in the summary. It can turn out wonky.
We also really want to describe here what the function does, not that it's a mock. That's a "what is it" doc, not a "what does it do".
-
-
-
-
-
-
-
-
-
-
-
-
- Change Summary:
-
Addressed some review changes
- Commit:
-
42072011b40f2fc773e72a6e8b72ea6d3f4cefa46b80371aad2fb42820d3ab589930c34dc7bd8d22
- Diff:
-
Revision 23 (+525 -52)
Checks run (2 succeeded)
- Change Summary:
-
More fixes
- Commit:
-
6b80371aad2fb42820d3ab589930c34dc7bd8d222f61c290da9cafe0a47ab39dd7b8f3ca0de9fea7
- Diff:
-
Revision 24 (+536 -52)
- Change Summary:
-
Addressed additional reviews
- Commit:
-
2f61c290da9cafe0a47ab39dd7b8f3ca0de9fea74624915cff9df95a1a37895b0c55f22bdd8cc403
- Diff:
-
Revision 25 (+565 -52)