コード例 #1
0
    def create(
        project: "ogr_pagure.PagureProject",
        title: str,
        body: str,
        private: Optional[bool] = None,
        labels: Optional[List[str]] = None,
        assignees: Optional[List[str]] = None,
    ) -> "Issue":
        if not project.has_issues:
            raise IssueTrackerDisabled()

        payload = {"title": title, "issue_content": body}
        if labels is not None:
            payload["tag"] = ",".join(labels)
        if private:
            payload["private"] = "true"
        if assignees and len(assignees) > 1:
            raise OperationNotSupported(
                "Pagure does not support multiple assignees")
        elif assignees:
            payload["assignee"] = assignees[0]

        new_issue = project._call_project_api("new_issue",
                                              data=payload,
                                              method="POST")["issue"]
        return PagureIssue(new_issue, project)
コード例 #2
0
ファイル: release.py プロジェクト: packit/ogr
 def get_list(project: "ogr_gitlab.GitlabProject") -> List["Release"]:
     if not hasattr(project.gitlab_repo, "releases"):
         raise OperationNotSupported(
             "This version of python-gitlab does not support release, please upgrade."
         )
     releases = project.gitlab_repo.releases.list(all=True)
     return [GitlabRelease(release, project) for release in releases]
コード例 #3
0
 def commit_comment(self,
                    commit: str,
                    body: str,
                    filename: str = None,
                    row: int = None) -> CommitComment:
     raise OperationNotSupported(
         "Commit comments are not supported on Pagure.")
コード例 #4
0
 def get(
     project: "ogr_pagure.PagureProject",
     identifier: Optional[int] = None,
     name: Optional[str] = None,
     tag_name: Optional[str] = None,
 ) -> "Release":
     raise OperationNotSupported()
コード例 #5
0
 def add_assignee(self, *assignees: str) -> None:
     if len(assignees) > 1:
         raise OperationNotSupported(
             "Pagure does not support multiple assignees")
     payload = {"assignee": assignees[0]}
     self.project._call_project_api("issue",
                                    str(self.id),
                                    "assign",
                                    data=payload,
                                    method="POST")
コード例 #6
0
ファイル: check_run.py プロジェクト: packit/ogr
    def get(
        project: "ogr_github.GithubProject",
        check_run_id: Optional[int] = None,
        commit_sha: Optional[str] = None,
    ) -> Optional["GithubCheckRun"]:
        """
        Retrieves GitHub check run as ogr object.

        Args:
            project: Project from which the check run is retrieved.
            check_run_id: Check run ID.

                Defaults to `None`, i.e. is not used for query.
            commit_sha: Commit SHA from which the check run is to be retrieved.
                If set, returns latest check run for the commit.

                Defaults to `None`, i.e. is not used for query.

        Returns:
            GithubCheckRun object or `None` if no check run is found.

        Raises:
            OperationNotSupported, in case there is no parameter for query set
                or both are set.
        """
        if check_run_id is not None and commit_sha:
            raise OperationNotSupported(
                "Cannot retrieve check run by both ID and commit hash")
        elif not (check_run_id is not None or commit_sha):
            raise OperationNotSupported(
                "Cannot retrieve check run by no criteria")

        if check_run_id is not None:
            return GithubCheckRun(
                project, project.github_repo.get_check_run(check_run_id))

        check_runs = project.github_repo.get_commit(
            commit_sha).get_check_runs()
        if check_runs.totalCount == 0:
            return None
        return GithubCheckRun(project, check_runs[0])
コード例 #7
0
ファイル: project.py プロジェクト: AHeadman-USGS/WaterGeoPy
 def get_releases(self) -> List[Release]:
     if not hasattr(self.gitlab_repo, "releases"):
         raise OperationNotSupported(
             "This version of python-gitlab does not support release, please upgrade."
         )
     releases = self.gitlab_repo.releases.list(all=True)
     return [
         self._release_from_gitlab_object(
             raw_release=release,
             git_tag=self._git_tag_from_tag_name(release.tag_name),
         ) for release in releases
     ]
コード例 #8
0
ファイル: project.py プロジェクト: packit/ogr
 def is_private(self) -> bool:
     host = urlparse(self.service.instance_url).hostname
     if host in [
             "git.centos.org",
             "git.stg.centos.org",
             "pagure.io",
             "src.fedoraproject.org",
             "src.stg.fedoraproject.org",
     ]:
         # private repositories are not allowed on generally used pagure instances
         return False
     raise OperationNotSupported(
         f"is_private is not implemented for {self.service.instance_url}."
         f"Please open issue in https://github.com/packit/ogr")
コード例 #9
0
    def fork_create(self, namespace: Optional[str] = None) -> "PagureProject":
        if namespace is not None:
            raise OperationNotSupported(
                "Pagure does not support forking to namespaces."
            )

        request_url = self.service.get_api_url("fork")
        self.service.call_api(
            url=request_url,
            method="POST",
            data={"repo": self.repo, "namespace": self.namespace, "wait": True},
        )
        fork = self._construct_fork_project()
        logger.debug(f"Forked to {fork.full_repo_name}")
        return fork
コード例 #10
0
 def get_forks(self) -> List["GitlabProject"]:
     try:
         forks = self.gitlab_repo.forks.list()
     except KeyError as ex:
         # > item = self._data[self._current]
         # > KeyError: 0
         # looks like some API weirdness
         raise OperationNotSupported(
             "Please upgrade python-gitlab to a newer version.") from ex
     return [
         GitlabProject(
             repo=fork.path,
             namespace=fork.namespace["full_path"],
             service=self.service,
         ) for fork in forks
     ]
コード例 #11
0
    def create(
        project: "ogr_github.GithubProject",
        title: str,
        body: str,
        private: Optional[bool] = None,
        labels: Optional[List[str]] = None,
        assignees: Optional[list] = None,
    ) -> "Issue":
        if private:
            raise OperationNotSupported(
                "Private issues are not supported by Github")

        github_issue = project.github_repo.create_issue(title=title,
                                                        body=body,
                                                        labels=labels or [],
                                                        assignees=assignees
                                                        or [])
        return GithubIssue(github_issue, project)
コード例 #12
0
ファイル: check_run.py プロジェクト: packit/ogr
    def change_status(
        self,
        status: Optional[GithubCheckRunStatus] = None,
        completed_at: Optional[datetime.datetime] = None,
        conclusion: Optional[GithubCheckRunResult] = None,
    ) -> None:
        """
        Changes the status of the check run and checks the validity of new state.

        Args:
            status: Status of the check run to be set. If set to completed, you
                must provide conclusion.

                Defaults to `None`.
            completed_at: Timestamp of completion of the check run. If set, you
                must provide conclusion.

                Defaults to `None`.
            conclusion: Conclusion/result of the check run. If only conclusion
                is set, status is automatically set to completed.

                Defaults to `None`.

        Raises:
            OperationNotSupported, if given completed or timestamp of completed
                without conclusion.
        """
        if not (status or completed_at or conclusion):
            return

        if (status == GithubCheckRunStatus.completed
                or completed_at) and conclusion is None:
            raise OperationNotSupported(
                "When provided completed status or completed at,"
                " you need to provide conclusion.")

        self.raw_check_run.edit(
            status=value_or_NotSet(status.name if status else None),
            conclusion=value_or_NotSet(
                conclusion.name if conclusion else None),
            completed_at=value_or_NotSet(completed_at),
        )
コード例 #13
0
 def request_access(self):
     raise OperationNotSupported("Not possible on Pagure")
コード例 #14
0
 def description(self, new_description: str) -> None:
     raise OperationNotSupported("Not possible on Pagure")
コード例 #15
0
ファイル: check_run.py プロジェクト: packit/ogr
    def create(
        project: "ogr_github.GithubProject",
        name: str,
        commit_sha: str,
        url: Optional[str] = None,
        external_id: Optional[str] = None,
        status: GithubCheckRunStatus = GithubCheckRunStatus.queued,
        started_at: Optional[datetime.datetime] = None,
        conclusion: Optional[GithubCheckRunResult] = None,
        completed_at: Optional[datetime.datetime] = None,
        output: Optional[GithubCheckRunOutput] = None,
        actions: Optional[List[Dict[str, str]]] = None,
    ) -> "GithubCheckRun":
        """
        Creates new check run.

        Args:
            project: Project where the check run is to be created.
            name: Name of the check run.
            commit_sha: Hash of the commit that check run is related to.
            url: URL with details of the run.

                Defaults to `None`.
            external_id: External ID that can be used internally by integrator.

                Defaults to `None`.
            status: Status of the check run.

                Defaults to queued.
            started_at: Timestamp of starting the check run.

                Defaults to `None`.
            conclusion: Conclusion of the check run. Should be set with status
                completed.

                Defaults to `None`.
            completed_at: Timestamp of completion of the check run. If set, you
                must provide conclusion.

                Defaults to `None`.
            output: Output of the check run.
            actions: List of possible follow-up actions for the check run.

        Returns:
            Created check run object.

        Raises:
            OperationNotSupported, if given completed status or completion
                timestamp and no conclusion.
        """

        if (completed_at or status
                == GithubCheckRunStatus.completed) and conclusion is None:
            raise OperationNotSupported(
                "When provided completed_at or completed status, "
                "you need to provide conclusion.")

        created_check_run = project.github_repo.create_check_run(
            name=name,
            head_sha=commit_sha,
            details_url=value_or_NotSet(url),
            external_id=value_or_NotSet(external_id),
            status=status.name,
            started_at=value_or_NotSet(started_at),
            conclusion=value_or_NotSet(
                conclusion.name if conclusion else None),
            completed_at=value_or_NotSet(completed_at),
            output=value_or_NotSet(output),
            actions=value_or_NotSet(actions),
        )

        return GithubCheckRun(project, created_check_run)
コード例 #16
0
 def edited(self) -> datetime.datetime:
     raise OperationNotSupported(
         "GitLab doesn't support edited on commit flags, for more info "
         "see https://github.com/packit/ogr/issues/413#issuecomment-729623702"
     )
コード例 #17
0
 def body(self, new_body: str) -> None:
     raise OperationNotSupported()
コード例 #18
0
 def get_latest(project: "ogr_pagure.PagureProject") -> Optional["Release"]:
     raise OperationNotSupported("Pagure API does not provide timestamps")
コード例 #19
0
ファイル: user.py プロジェクト: mmuzila/ogr
 def get_email(self) -> str:
     # Not supported by Pagure
     raise OperationNotSupported(
         "Pagure does not support retrieving of user's email address")
コード例 #20
0
 def edit_release(self, name: str, message: str) -> None:
     raise OperationNotSupported("edit_release not supported on Pagure")
コード例 #21
0
ファイル: project.py プロジェクト: packit/ogr
 def get_commit_comments(self, commit: str) -> List[CommitComment]:
     raise OperationNotSupported(
         "Commit comments are not supported on Pagure.")
コード例 #22
0
 def request_access(self):
     raise OperationNotSupported("Not possible on GitHub")
コード例 #23
0
ファイル: project.py プロジェクト: packit/ogr
 def get_contributors(self) -> Set[str]:
     raise OperationNotSupported(
         "Pagure doesn't provide list of contributors")