Skip to content

Commit 5c081a8

Browse files
pr fix
1 parent 6a4c198 commit 5c081a8

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/gitingest/clone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async def clone_repo(config: CloneConfig, *, token: str | None = None) -> None:
2626
"""Clone a repository to a local path based on the provided configuration.
2727
2828
This function handles the process of cloning a Git repository to the local file system.
29-
It can clone a specific branch or commit if provided, and it raises exceptions if
29+
It can clone a specific branch, tag, or commit if provided, and it raises exceptions if
3030
any errors occur during the cloning process.
3131
3232
Parameters

src/gitingest/query_parser.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,17 @@ async def _parse_remote_repo(source: str, token: str | None = None) -> Ingestion
188188
# Try to resolve a tag
189189
parsed.tag = await _configure_branch_or_tag(
190190
remaining_parts,
191-
url,
192-
configure="tags",
191+
url=url,
192+
ref_type="tags",
193193
token=token,
194194
)
195195

196196
# If no tag found, try to resolve a branch
197197
if not parsed.tag:
198198
parsed.branch = await _configure_branch_or_tag(
199199
remaining_parts,
200-
url,
201-
configure="branches",
200+
url=url,
201+
ref_type="branches",
202202
token=token,
203203
)
204204

@@ -211,8 +211,9 @@ async def _parse_remote_repo(source: str, token: str | None = None) -> Ingestion
211211

212212
async def _configure_branch_or_tag(
213213
remaining_parts: list[str],
214+
*,
214215
url: str,
215-
configure: str,
216+
ref_type: str,
216217
token: str | None = None,
217218
) -> str | None:
218219
"""Configure the branch or tag based on the remaining parts of the URL.
@@ -223,8 +224,8 @@ async def _configure_branch_or_tag(
223224
The remaining parts of the URL path.
224225
url : str
225226
The URL of the repository.
226-
configure : str
227-
The type of object to configure. Can be "branches" or "tags".
227+
ref_type : str
228+
The type of reference to configure. Can be "branches" or "tags".
228229
token : str | None
229230
GitHub personal access token (PAT) for accessing private repositories.
230231
@@ -236,21 +237,21 @@ async def _configure_branch_or_tag(
236237
Raises
237238
------
238239
ValueError
239-
If the ``configure`` parameter is not "branches" or "tags".
240+
If the ``ref_type`` parameter is not "branches" or "tags".
240241
241242
"""
242-
if configure not in ("branches", "tags"):
243-
msg = f"Invalid configure type: {configure}"
243+
if ref_type not in ("branches", "tags"):
244+
msg = f"Invalid reference type: {ref_type}"
244245
raise ValueError(msg)
245246

246-
to_fetch = "tags" if configure == "tags" else "branches"
247+
_ref_type = "tags" if ref_type == "tags" else "branches"
247248

248249
try:
249250
# Fetch the list of branches or tags from the remote repository
250-
branches_or_tags: list[str] = await fetch_remote_branches_or_tags(url, fetch=to_fetch, token=token)
251+
branches_or_tags: list[str] = await fetch_remote_branches_or_tags(url, ref_type=_ref_type, token=token)
251252
except RuntimeError as exc:
252253
# If remote discovery fails, we optimistically treat the first path segment as the branch/tag.
253-
msg = f"Warning: Failed to fetch {to_fetch}: {exc}"
254+
msg = f"Warning: Failed to fetch {_ref_type}: {exc}"
254255
warnings.warn(msg, RuntimeWarning, stacklevel=2)
255256
return remaining_parts.pop(0) if remaining_parts else None
256257

src/gitingest/utils/git_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,15 @@ def _parse_github_url(url: str) -> tuple[str, str, str]:
196196
return parsed.hostname, owner, repo
197197

198198

199-
async def fetch_remote_branches_or_tags(url: str, *, fetch: str, token: str | None = None) -> list[str]:
199+
async def fetch_remote_branches_or_tags(url: str, *, ref_type: str, token: str | None = None) -> list[str]:
200200
"""Fetch the list of branches or tags from a remote Git repository.
201201
202202
Parameters
203203
----------
204204
url : str
205205
The URL of the Git repository to fetch branches or tags from.
206-
fetch: str
207-
The type of object to fetch. Can be "branches" or "tags".
206+
ref_type: str
207+
The type of reference to fetch. Can be "branches" or "tags".
208208
token : str | None
209209
GitHub personal access token (PAT) for accessing private repositories.
210210
@@ -216,11 +216,11 @@ async def fetch_remote_branches_or_tags(url: str, *, fetch: str, token: str | No
216216
Raises
217217
------
218218
ValueError
219-
If the ``fetch`` parameter is not "branches" or "tags".
219+
If the ``ref_type`` parameter is not "branches" or "tags".
220220
221221
"""
222-
if fetch not in ("branches", "tags"):
223-
msg = f"Invalid fetch type: {fetch}"
222+
if ref_type not in ("branches", "tags"):
223+
msg = f"Invalid fetch type: {ref_type}"
224224
raise ValueError(msg)
225225

226226
cmd = ["git"]
@@ -231,7 +231,7 @@ async def fetch_remote_branches_or_tags(url: str, *, fetch: str, token: str | No
231231

232232
cmd += ["ls-remote"]
233233

234-
fetch_tags = fetch == "tags"
234+
fetch_tags = ref_type == "tags"
235235
to_fetch = "tags" if fetch_tags else "heads"
236236

237237
cmd += [f"--{to_fetch}"]

0 commit comments

Comments
 (0)