Improve json usefulness for post-commit hook
Submitted
Updated 2 months, 3 weeks ago
| Jonathan Ellis | Reviewers | ||
| reviewboard | |||
| None | Review Board SVN | ||
the main point of this change is to allow a staff user to specify submit_as=a-different-user when creating a review request so that user will be the one notified of reviews, etc. this enables using a post-commit hook to auto-create reviews for all or part of a repository. there are some side concerns related to this: * basedir must be allowed to be empty when creating diffs against a svn repository as opposed to a working copy. that is what the diffviewer change does; for the web interface the functionality is identical, but the json manually rips out the basedir when necessary, allowing a svn repo diff to be treated as "absolute." * added is_visible_to and is_mutable_by methods to the Request models to encapsulate the notion that "staff can always view and modify requests" * moved sending of mail into the models to avoid duplication of code in json and view * json new_diff includes traceback when something unexpected goes wrong * add get_changeset to svn to allow update_from_changenum for that scm
Posted 10 months ago (January 25th, 2008, 3:20 p.m.)
-
/trunk/reviewboard/diffviewer/forms.py (Diff revision 1) 43 if tool.get_diffs_use_absolute_paths():
43 if 'basedir' in self.fields:
-
This should still take into account tool.get_diffs_use_absolute_paths.
-
/trunk/reviewboard/reviews/models.py (Diff revision 1) 399 -
Excess whitespace.
-
/trunk/reviewboard/reviews/models.py (Diff revision 1) 400 def is_visible_to(self, user):
401 return self.public or self.is_mutable_by(user)
402 403 def is_mutable_by(self, user):
404 return self.submitter == user or user.is_staff
-
We should be making use of Django's permissions models, not specifically checking for is_staff. People who are staff do not necessarily have the permissions for modifying data. We have people marked as staff who can only add/modify review groups, for instance. Also, could you add some simple doc blocks?
-
/trunk/reviewboard/reviews/views.py (Diff revision 1) 336 raise Exception('cannot publish with no reviewers set')
-
Excess whitespace. This should start with a capital C and be internationalized.
-
/trunk/reviewboard/scmtools/svn.py (Diff revision 1) 22 def callback_ssl(trust_dict):
23 return True, trust_dict['failures'], False
-
It'd be nice to move this into SVNTool directly and provide documentation for the method, specifying what it does and the return values.
-
/trunk/reviewboard/scmtools/svn.py (Diff revision 1) 65 def get_changeset(self, changesetid):
-
Can you add a doc block for this and make it clear this is for changes that are already committed?
-
/trunk/reviewboard/scmtools/svn.py (Diff revision 1) 71 def pathinfo(path):
72 return path['action'] + ' ' + path['path']
73 cs.description = '\n'.join(pathinfo(path) for path in log['changed_paths'])
-
I'd rather pathinfo not be its own function. This can be done inline. cs.description = '\n'.join("%s %s" % (path['action'], path['path']) for path in log['changed_paths']) -
/trunk/reviewboard/scmtools/svn.py (Diff revision 1) 76 -
Excess whitespace.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 392 repository_id = request.POST.get('repository_id', None)
391 repository_id = request.POST.get('repository_id')
-
This should stay None.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 392 submit_as = request.POST.get('submit_as')
-
This should default to None in the parameter.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 394 if not request.user.is_staff:
-
Permissions checking.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 396 try:
397 user = User.objects.filter(username=submit_as)[0]
398 except IndexError:
399 return JsonResponseError(request, INVALID_USER)
-
filter is incorrect here. You should be using User.objects.get.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 1015 # allow no basedir for diffs done against the repository root -
Comments should be in sentence case, with a trailing '.' This should also have a blank line before it. If you could rewrite this to make it more clear, it would help. The "Allow no basedir" is grammatically awkward.
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 1016 if 'basedir' in form_data and not form_data['basedir']:
1017 del(form.fields['basedir'])
-
I'd rather get rid of this change here. The code that handles the basedir field in forms should take this into account by changing it to "/".
-
/trunk/reviewboard/webapi/json.py (Diff revision 1) 1039 'path': [str(e)]
1042 'path': [traceback.format_exception(*sys.exc_info())]
-
I'm not sure this is correct. A traceback is not really what we want here. It's useful information but perhaps wrong for this field. Maybe 'path_traceback'? Then the caller can decide what to show.
Posted 2 months, 3 weeks ago (August 27th, 2008, 2:45 a.m.)
I think we got everything we're going to get out of this, now that the individual parts have been broken up and reviewed.