Posts a comment to the GitHub PR if the diff results have issues.
327243
def post_pr_comment(self, patch):
        
        if self.has_violations:
            post_pr_comment = True

            # Attempt to post a PR review. If posting the PR review fails because the bot account
            # does not have permission to review the PR then simply revert to posting a regular PR
            # comment.
            try:
                logger.info('Deleting old PR review comments')
                self.git_client.delete_pull_request_review_comments(self.config.pr)

                logger.info('Creating PR review')
                self.git_client.create_pull_request_review(self.config.pr, patch, self._diff_violations)
                post_pr_comment = False
            except GitClientError as e:
                # TODO: Make `create_pull_request_review` raise an `UnauthorizedError`
                # so that we don't have to check for a specific message in the exception
                if 'Viewer does not have permission to review this pull request' in str(e):
                    logger.warning("Could not post PR review (the account didn't have permission)")
                    pass
                else:
                    raise

            if post_pr_comment:
                logger.info('Deleting old PR comment')
                self.git_client.delete_pull_request_comments(self.config.pr)

                logger.info('Creating PR comment')
                comment = build_pr_comment(self.config, self.violations)
                self.git_client.create_pull_request_comment(self.config.pr, comment)
604822
def get_review_comment(self, id):
        
        assert isinstance(id, (int, long)), id
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self._parentUrl(self.url) + "/comments/" + str(id)
        )
        return github.PullRequestComment.PullRequestComment(self._requester, headers, data, completed=True)
1105453
def check_conflict_and_comment()
      results = check_conflict()

      results.each do |result|
        next if result[:mergeable]
        message = "<p>This PR conflicts with <a href=\"#{result[:pull_request][:html_url]}\">##{result[:pull_request][:number]}</a>.</p>"
        table = '<table><thead><tr><th width="100%">File</th><th>Line</th></tr></thead><tbody>' + result[:conflicts].map do |conflict|
          file = conflict[:file]
          line = conflict[:line]
          line_link = "#{result[:pull_request][:head][:repo][:html_url]}/blob/#{result[:pull_request][:head][:ref]}/#{file}#L#{line}"
          "<tr><td>#{file}</td><td><a href=\"#{line_link}\">#L#{line}</a></td></tr>"
        end.join('') + '</tbody></table>'
        puts (message + table)
        warn("<div>" + message + table + "</div>")
      end

      results
    end
173434
def edit(user_name, repo_name, comment_id, params={})
      _update_user_repo_params(user_name, repo_name)
      _validate_user_repo_params(user, repo) unless user? && repo?
      _validate_presence_of comment_id

      normalize! params
      # _merge_mime_type(:issue_comment, params)
      filter! VALID_ISSUE_COMMENT_PARAM_NAME, params
      assert_required_keys(%w[ content ], params)

      put_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/comments/#{comment_id}", params)
    end
622034
def publish(self):
        '''
        
        '''

        self.cleanup

        remote = self.remote
        branch = self.branch
        return self.m(
            'pushing changes to %s/%s' % (remote, branch),
            cmdd=dict(
                cmd='git push -u %s %s' % (remote, branch),
                cwd=self.local
            ),
            more=dict(remote=remote, branch=branch)
        )
1268349
def list_pr_comments(repo: GithubRepository, pull_id: int
                     ) -> List[Dict[str, Any]]:
    
    url = ("https://api.github.com/repos/{}/{}/issues/{}/comments"
           "?access_token={}".format(repo.organization,
                                     repo.name,
                                     pull_id,
                                     repo.access_token))
    response = requests.get(url)
    if response.status_code != 200:
        raise RuntimeError(
            'Comments get failed. Code: {}. Content: {}.'.format(
                response.status_code, response.content))
    payload = json.JSONDecoder().decode(response.content.decode())
    return payload
836911
def add_progress(kwargs, git, progress):
    """"""
    if progress is not None:
        v = git.version_info[:2]
        if v >= (1, 7):
            kwargs['progress'] = True
        # END handle --progress
    # END handle progress
    return kwargs
1047986
function commentIssue (client, repo, number, comment) {
  debug("commentIssue", repo, number, comment);

  return client.commentIssue(_.merge(extractRepo(repo), {
    "number": number,
    "body":   comment
  })).then(function (comment) {
    return {
      "type":   "comment",
      "issue":  number,
      "url":    comment.html_url
    };
  });
}
1062031
function isDirty () {
  return pify(git.raw.bind(git))(['status', '-s'])
    .then((out) => {
      if (out && out.trim().length > 0) {
        throw new Error('Dirty git repo, aborting')
      }
    })
}
233443
def addcomment(self, comment, private=False):
        
        # Note: fedora bodhi uses this function
        vals = self.bugzilla.build_update(comment=comment,
                                          comment_private=private)
        log.debug("addcomment: update=%s", vals)

        return self.bugzilla.update_bugs(self.bug_id, vals)
1282220
def publish_report(report, args, old_commit, new_commit):
    """"""
    # Print the report to stdout unless the user specified --quiet.
    output = ""

    if not args.quiet and not args.gist and not args.file:
        return report

    if args.gist:
        gist_url = post_gist(report, old_commit, new_commit)
        output += "\nReport posted to GitHub Gist: {0}".format(gist_url)

    if args.file is not None:
        with open(args.file, 'w') as f:
            f.write(report.encode('utf-8'))
        output += "\nReport written to file: {0}".format(args.file)

    return output
1203316
def main(github_token, github_api_url, progress):
    """"""
    global progress_reporter_cls
    progress_reporter_cls.reportProgress = sys.stdout.isatty() and progress
    if progress_reporter_cls.reportProgress:
        progress_reporter_cls = _progress_bar
    global _github_token_cli_arg
    _github_token_cli_arg = github_token
    global _github_api_url
    _github_api_url = github_api_url
587142
def start_review(self):
        """"""
        if self.set_status:
            self.github_repo.create_status(
                state="pending",
                description="Static analysis in progress.",
                context="inline-plz",
                sha=self.last_sha,
            )
618147
def edit_required_status_checks(self, strict=github.GithubObject.NotSet, contexts=github.GithubObject.NotSet):
        
        assert strict is github.GithubObject.NotSet or isinstance(strict, bool), strict
        assert contexts is github.GithubObject.NotSet or all(isinstance(element, (str, unicode)) or isinstance(element, (str, unicode)) for element in contexts), contexts

        post_parameters = {}
        if strict is not github.GithubObject.NotSet:
            post_parameters["strict"] = strict
        if contexts is not github.GithubObject.NotSet:
            post_parameters["contexts"] = contexts
        headers, data = self._requester.requestJsonAndCheck(
            "PATCH",
            self.protection_url + "/required_status_checks",
            input=post_parameters
        )
305080
function attachCommentReply(comment) {
    return function reply(body, callback) {
        github.replyToReviewComment(this.repo.data.owner.login, this.repo.data.name, this.data.number, comment.id, body, callback);
    }.bind(this);
}
320189
def publish(context):
    """"""
    commit_version_change(context)

    if context.github:
        # github token
        project_settings = project_config(context.module_name)
        if not project_settings['gh_token']:
            click.echo('You need a GitHub token for changes to create a release.')
            click.pause(
                'Press [enter] to launch the GitHub "New personal access '
                'token" page, to create a token for changes.'
            )
            click.launch('https://github.com/settings/tokens/new')
            project_settings['gh_token'] = click.prompt('Enter your changes token')

            store_settings(context.module_name, project_settings)
        description = click.prompt('Describe this release')

        upload_url = create_github_release(
            context, project_settings['gh_token'], description
        )

        upload_release_distributions(
            context,
            project_settings['gh_token'],
            build_distributions(context),
            upload_url,
        )

        click.pause('Press [enter] to review and update your new release')
        click.launch(
            '{0}/releases/tag/{1}'.format(context.repo_url, context.new_version)
        )
    else:
        tag_and_push(context)
777738
def build_pr_comment(config, violations):
    
    template = env.get_template('pr_comment.txt')
    return template.render(violations=violations, LINTLY_IDENTIFIER=LINTLY_IDENTIFIER)