Skip to content

Commit

Permalink
update-language-issue: create new issue if the issue cannot be found (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiaanspeck authored Sep 10, 2024
1 parent 1048273 commit c9f3acb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,30 @@ def create_colored_line(start_color: str, text: str) -> str:
return f"{start_color}{text}{Colors.RESET}"


def create_github_issue(title: str) -> list[dict]:
command = [
"gh",
"api",
"--method",
"POST",
"-H",
"Accept: application/vnd.github+json",
"-H",
"X-GitHub-Api-Version: 2022-11-28",
"/repos/tldr-pages/tldr-maintenance/issues",
"-f",
f"title={title}"
]

result = subprocess.run(command, capture_output=True, text=True)
data = json.loads(result.stdout)

return = [
{"number": issue["number"], "title": issue["title"], "url": issue["html_url"]}
for issue in data
]


def get_github_issue(title: str = None) -> list[dict]:
command = [
"gh",
Expand Down
4 changes: 4 additions & 0 deletions scripts/update-language-issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
get_tldr_root,
get_check_pages_dir,
get_locale,
create_github_issue,
get_github_issue,
update_github_issue,
)
Expand Down Expand Up @@ -171,6 +172,9 @@ def main():

issue_number = get_github_issue(title)["number"]

if not issue_number:
issue_number = create_github_issue(title)["number"]

markdown_content = f"# {title}\n\n"

lang_data = parse_language_directory(lang_dir)
Expand Down

0 comments on commit c9f3acb

Please sign in to comment.