Skip to content

Commit 2cff8ca

Browse files
feat: add gist.github.com support and fix ingest_async bug (#184)
Signed-off-by: Filip Christiansen <22807962+filipchristiansen@users.noreply.github.com>
1 parent 6f95edd commit 2cff8ca

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/gitingest/query_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"bitbucket.org",
2424
"gitea.com",
2525
"codeberg.org",
26+
"gist.github.com",
2627
"gitingest.com",
2728
]
2829

src/gitingest/repository_ingest.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ async def ingest_async(
5555
TypeError
5656
If `clone_repo` does not return a coroutine, or if the `source` is of an unsupported type.
5757
"""
58+
repo_cloned = False
59+
5860
try:
5961
parsed_query: ParsedQuery = await parse_query(
6062
source=source,
@@ -75,16 +77,18 @@ async def ingest_async(
7577
commit=parsed_query.commit,
7678
branch=selected_branch,
7779
)
78-
clone_result = clone_repo(clone_config)
80+
clone_coroutine = clone_repo(clone_config)
7981

80-
if inspect.iscoroutine(clone_result):
82+
if inspect.iscoroutine(clone_coroutine):
8183
if asyncio.get_event_loop().is_running():
82-
await clone_result
84+
await clone_coroutine
8385
else:
84-
asyncio.run(clone_result)
86+
asyncio.run(clone_coroutine)
8587
else:
8688
raise TypeError("clone_repo did not return a coroutine as expected.")
8789

90+
repo_cloned = True
91+
8892
summary, tree, content = run_ingest_query(parsed_query)
8993

9094
if output is not None:
@@ -94,8 +98,7 @@ async def ingest_async(
9498
return summary, tree, content
9599
finally:
96100
# Clean up the temporary directory if it was created
97-
if parsed_query.url:
98-
# Clean up the temporary directory
101+
if repo_cloned:
99102
shutil.rmtree(TMP_BASE_PATH)
100103

101104

0 commit comments

Comments
 (0)