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

Modernize Codebase and Enhance CI Workflow #67

Merged
merged 15 commits into from
Dec 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
resolve merge conflicts
  • Loading branch information
filipchristiansen committed Dec 28, 2024
commit 075b4549cef33b2636b7da7ed33bfe7efe4ffa7e
11 changes: 6 additions & 5 deletions src/gitingest/parse_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import string
import uuid
from typing import Any, Dict, List, Optional, Union
from urllib.parse import unquote

from gitingest.ignore_patterns import DEFAULT_IGNORE_PATTERNS

Expand All @@ -25,7 +26,7 @@ def parse_url(url: str) -> Dict[str, Any]:

url = url.split(" ")[0]
url = unquote(url) # Decode URL-encoded characters

if not url.startswith('https://'):
url = 'https://' + url

Expand All @@ -49,7 +50,7 @@ def parse_url(url: str) -> Dict[str, Any]:
if len(path_parts) > 3:

parsed["type"] = path_parts[2] # Usually 'tree' or 'blob'

# Find the commit hash or reconstruct the branch name
remaining_parts = path_parts[3:]
if remaining_parts[0] and len(remaining_parts[0]) == 40 and all(c in HEX_DIGITS for c in remaining_parts[0]):
Expand All @@ -61,14 +62,15 @@ def parse_url(url: str) -> Dict[str, Any]:
if part in ('tree', 'blob'):
# Found another type indicator, everything before this was the branch name
parsed["branch"] = "/".join(remaining_parts[:i])
parsed["subpath"] = "/" + "/".join(remaining_parts[i+2:]) if len(remaining_parts) > i+2 else "/"
parsed["subpath"] = (
"/" + "/".join(remaining_parts[i + 2 :]) if len(remaining_parts) > i + 2 else "/"
)
break
else:
# No additional type indicator found, assume everything is part of the branch name
parsed["branch"] = "/".join(remaining_parts)
parsed["subpath"] = "/"


return parsed


Expand Down Expand Up @@ -130,7 +132,6 @@ def parse_query(
include_patterns: Optional[Union[List[str], str]] = None,
ignore_patterns: Optional[Union[List[str], str]] = None,
) -> Dict[str, Any]:

"""
Parses the input source to construct a query dictionary with specified parameters.

Expand Down
Loading