Skip to content

fix: solve some of the problems with snippets and languages #605

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

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Changes from all 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
10 changes: 10 additions & 0 deletions src/codegate/pipeline/extract_snippets/extract_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
# format ` ```python ` in output snippets
if filename and not matched_language and "." not in filename:
lang = filename
if lang not in available_languages:
# try to get it from the extension
lang = ecosystem_from_message(filename)
if lang not in available_languages:
lang = None
filename = None
else:
# Determine language from the message, either by the short
Expand All @@ -118,6 +123,11 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
if lang not in available_languages:
lang = None

#  just correct the typescript exception
lang_map = {
"typescript": "javascript"
}
lang = lang_map.get(lang, lang)
snippets.append(CodeSnippet(filepath=filename, code=content, language=lang))

return snippets
Expand Down
Loading