Esempio n. 1
0
def _update_issue(
    ogr_project: BaseGitProject,
    trace_directory: str,
    issue: Issue,
    agg_list: List[AugSaBug],
    commit_hash: Optional[str] = None,
) -> None:
    title, body = _generate_issue_title_and_body(
        ogr_project=ogr_project,
        trace_directory=trace_directory,
        agg_list=agg_list,
        commit_hash=commit_hash,
    )
    if issue.title != title:
        issue.title = title
    if issue.description != body:
        issue.description = body
Esempio n. 2
0
 def _issue_from_github_object(github_issue: GithubIssue) -> Issue:
     return Issue(
         title=github_issue.title,
         id=github_issue.number,
         status=IssueStatus[github_issue.state],
         url=github_issue.html_url,
         description=github_issue.body,
         author=github_issue.user.login,
         created=github_issue.created_at,
     )
Esempio n. 3
0
 def _issue_from_pagure_dict(self, issue_dict: dict) -> Issue:
     return Issue(
         title=issue_dict["title"],
         id=issue_dict["id"],
         status=IssueStatus[issue_dict["status"].lower()],
         url=self._get_project_url("issue", str(issue_dict["id"])),
         description=issue_dict["content"],
         author=issue_dict["user"]["name"],
         created=datetime.datetime.fromtimestamp(int(issue_dict["date_created"])),
     )
Esempio n. 4
0
 def _issue_from_gitlab_object(gitlab_issue) -> Issue:
     return Issue(
         title=gitlab_issue.title,
         id=gitlab_issue.iid,
         url=gitlab_issue.web_url,
         description=gitlab_issue.description,
         status=gitlab_issue.state,
         author=gitlab_issue.author["username"],
         created=gitlab_issue.created_at,
     )
Esempio n. 5
0
 def _issue_from_gitlab_object(gitlab_issue) -> Issue:
     return Issue(
         title=gitlab_issue.title,
         id=gitlab_issue.iid,
         url=gitlab_issue.web_url,
         description=gitlab_issue.description,
         status=IssueStatus.open if gitlab_issue.state == "opened" else
         IssueStatus[gitlab_issue.state],
         author=gitlab_issue.author["username"],
         created=gitlab_issue.created_at,
     )
Esempio n. 6
0
 def _issue_from_github_object(github_issue: GithubIssue) -> Issue:
     if github_issue.pull_request:
         raise GithubAPIException(
             f"Requested issue #{github_issue.number} is a pull request")
     return Issue(
         title=github_issue.title,
         id=github_issue.number,
         status=IssueStatus[github_issue.state],
         url=github_issue.html_url,
         description=github_issue.body,
         author=github_issue.user.login,
         created=github_issue.created_at,
     )
Esempio n. 7
0
    def _add_refresh_comment(self, exc: PipenvError, issue: Issue):
        """Create a refresh comment to an issue if the given master has some changes."""
        if self.sha in issue.description:
            _LOGGER.debug(
                "No need to update refresh comment, the issue is up to date")
            return

        for issue_comment in issue.get_comments():
            if self.sha in issue_comment.body:
                _LOGGER.debug(
                    f"No need to update refresh comment, comment for the current "
                    f"master {self.sha[:7]!r} found in a comment")
                break
        else:
            issue.comment(
                ISSUE_COMMENT_UPDATE_ALL.format(
                    sha=self.sha,
                    slug=self.slug,
                    environment_details=self.get_environment_details(),
                    dependency_graph=self.get_dependency_graph(graceful=True),
                    **exc.char_limit_dict(MAX_PIPENV_CMD_LEN),
                ))
Esempio n. 8
0
 def add_assignees(self, issue: Issue, assignees: List[str]):
     """Add assignees to issues for all GitForges."""
     if isinstance(self.service, GithubService):
         issue._raw_issue.add_to_assignees(*assignees)
     elif isinstance(self.service, GitlabService):
         ids = []
         for username in assignees:
             ids.append(
                 self.service.gitlab_instance.users.list(
                     username=username)[0].id)
         issue._raw_issue.assignee_ids = ids
         issue._raw_issue.save()
     elif isinstance(self.service, PagureService):
         if len(assignees) != 1:
             raise ValueError(
                 "Pagure only supports assigning a single user to an issue."
             )
         data = {"assignee": assignees[0]}
         updated_issue = self.project._call_project_api("issue",
                                                        str(issue.id),
                                                        method="POST",
                                                        data=data)
         issue._raw_issue = updated_issue["issue"]
Esempio n. 9
0
 def can_close_issue(self, username: str, issue: Issue) -> bool:
     return issue.can_close(username)
Esempio n. 10
0
 def _advise_issue_is_fresh(self, issue: Issue):
     return not issue.get_comments(author=APP_NAME)