コード例 #1
0
ファイル: tracker.py プロジェクト: honestica/ywh2bugtracker
 def _create_issue(
     self,
     github_repository: Repository,
     title: str,
     body: str,
 ) -> Issue:
     try:
         return github_repository.create_issue(
             title=title,
             body=body,
         )
     except GithubException as e:
         raise GitHubTrackerClientError(
             f'Unable to create issue for project {self.configuration.project} to GitHub',
         ) from e
コード例 #2
0
ファイル: notify.py プロジェクト: rbuffat/eli_watchdog
def create_github_issue(repo: Repository, imagery_filepath: str,
                        imagery_name: str, reason: str, days: int) -> None:
    """Create new github issue

    Parameters
    ----------
    repo : Repository
        The repository to query
    imagery_filepath : str
        The path to the file the issue is created for
    imagery_name : str
        The name of the imagery
    reason : str
        The reason why the imagery is broken
    days : int
        The number of days the source is broken
    """
    try:

        contributors = query_contributors(repo, imagery_filepath)

        title = f'[Watchdog] Imagery "{imagery_name}": {imagery_filepath} broken'
        body_lines = [
            f"Watchdog failed for {days} consecutive days for:",
            f'"{imagery_name}" -> [{imagery_filepath}](https://github.com/{GITHUB_REPO}/tree/gh-pages/{imagery_filepath})',
            "",
            "Reason:",
            f"{reason}",
            "",
            "CC contributors to this imagery:",
            f"{', '.join([f'@{contributor}' for contributor in contributors])}",
        ]
        body = "\n".join(body_lines)
        repo.create_issue(title=title, body=body, labels=["imagery"])
    except Exception as e:
        print(f"Failed to create issue: {e}")
コード例 #3
0
def create_and_show_issue(
    dry_run: bool,
    body: str,
    repo: Repository,
    title: str,
    milestone: Optional[Milestone],
    project: Optional[Project],
    labels: list[Label],
    column: Optional[ProjectColumn],
    assignees: list[NamedUser],
):
    issue = None
    if not dry_run:
        issue = repo.create_issue(
            title=title or body,
            body=body if title else "",
            assignees=assignees,
            labels=labels,
            milestone=(milestone or github.GithubObject.NotSet),
        )
        if column is not None:
            column.create_card(content_id=issue.id, content_type="Issue")
        url = issue.html_url
    else:
        url = None

    ui.show(
        title=title,
        right_of_title=with_link(issue),
        description=body,
        labels=map(lambda l: to_ui_label(l, repo), labels),
        card_title=get_card_title(repo),
        milestone=with_link(milestone) if milestone else None,
        assignees=list(
            map(linkify_github_username,
                assignees)),  # maps are generators, and generators exhaust!
        project=with_link(project) if project else None,
        project_column=ui.href(column.name, project.html_url)
        if column else None,
        url=url,
    )