Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-language-issue: create new issue if the issue cannot be found #126

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions scripts/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@ 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}"
sebastiaanspeck marked this conversation as resolved.
Show resolved Hide resolved
]

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