Skip to content

Commit 8106c53

Browse files
authored
Merge pull request #605 from stacklok/fix_package_detection
fix: solve some of the problems with snippets and languages
2 parents d96b27c + b8a1f48 commit 8106c53

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/codegate/pipeline/extract_snippets/extract_snippets.py

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
9898
# format ` ```python ` in output snippets
9999
if filename and not matched_language and "." not in filename:
100100
lang = filename
101+
if lang not in available_languages:
102+
# try to get it from the extension
103+
lang = ecosystem_from_message(filename)
104+
if lang not in available_languages:
105+
lang = None
101106
filename = None
102107
else:
103108
# Determine language from the message, either by the short
@@ -118,6 +123,11 @@ def extract_snippets(message: str) -> List[CodeSnippet]:
118123
if lang not in available_languages:
119124
lang = None
120125

126+
#  just correct the typescript exception
127+
lang_map = {
128+
"typescript": "javascript"
129+
}
130+
lang = lang_map.get(lang, lang)
121131
snippets.append(CodeSnippet(filepath=filename, code=content, language=lang))
122132

123133
return snippets

0 commit comments

Comments
 (0)