Changeset - 93e055489e68
[Not reviewed]
default
0 2 0
Mads Kiilerich - 10 years ago 2015-06-19 18:06:39
madski@unity3d.com
pullrequsts: really create a comment when creating a PR and setting status to 'under review'

14d75d4b03cd changed the pullrequest creation status change comment text from
redundant blurb to just an empty string. Empty comments are however only
created if changing the status ... and in this case we didn't tell the comment
creator that it actually was a status change.

As a result of this, we ended up breaking the implicit invariant that all
status updates have a comment. That showed up as errors dereferencing None when
displaying changesets.
2 files changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
kallithea/model/comment.py
Show inline comments
 
@@ -161,25 +161,25 @@ class ChangesetCommentsModel(BaseModel):
 

	
 
    def create(self, text, repo, user, revision=None, pull_request=None,
 
               f_path=None, line_no=None, status_change=None, closing_pr=False,
 
               send_email=True):
 
        """
 
        Creates a new comment for either a changeset or a pull request.
 
        status_change and closing_pr is only for the optional email.
 

	
 
        Returns the created comment.
 
        """
 
        if not status_change and not text:
 
            log.warning('Missing text for comment, skipping...')
 
            return
 
            return None
 

	
 
        repo = self._get_repo(repo)
 
        user = self._get_user(user)
 
        comment = ChangesetComment()
 
        comment.repo = repo
 
        comment.author = user
 
        comment.text = text
 
        comment.f_path = f_path
 
        comment.line_no = line_no
 

	
 
        if revision:
 
            comment.revision = revision
kallithea/model/pull_request.py
Show inline comments
 
@@ -89,25 +89,26 @@ class PullRequestModel(BaseModel):
 
        new.description = description
 
        new.author = created_by_user
 
        Session().add(new)
 
        Session().flush()
 

	
 
        #reset state to under-review
 
        from kallithea.model.comment import ChangesetCommentsModel
 
        comment = ChangesetCommentsModel().create(
 
            text=u'',
 
            repo=org_repo,
 
            user=new.author,
 
            pull_request=new,
 
            send_email=False
 
            send_email=False,
 
            status_change=ChangesetStatus.STATUS_UNDER_REVIEW,
 
        )
 
        ChangesetStatusModel().set_status(
 
            org_repo,
 
            ChangesetStatus.STATUS_UNDER_REVIEW,
 
            new.author,
 
            comment,
 
            pull_request=new
 
        )
 

	
 
        mention_recipients = set(User.get_by_username(username, case_insensitive=True)
 
                                 for username in extract_mentioned_users(new.description))
 
        self.__add_reviewers(new, reviewers, mention_recipients)
0 comments (0 inline, 0 general)