Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: consistent cloning & pattern-handling#388

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
filipchristiansen wants to merge9 commits intomain
base:main
Choose a base branch
Loading
fromresolve-commit

Conversation

filipchristiansen
Copy link
Contributor

@filipchristiansenfilipchristiansen commentedJul 6, 2025
edited
Loading

✨ Refactor: consistent cloning & pattern-handling

Closes#196
Closes#344
Prepares for#342 (digest prefix/suffix) and#343 (caching)

Why

  • Cloning behaved differently depending on whether they supplied a branch, tag or commit.
    Caching and reproducibility suffered.
  • Pattern handling lived inquery_parser and duplicated ignore/include logic.
    Hard to unit-test and reuse.
  • Windows CI occasionally failed when temp clones contained read-only
    packed-object files.
    Shallow-clone cleanup broke with WinError 5.

What’s new

  • Unified commit resolution
    utils.git_utils.resolve_commit() guarantees we always fetch the exact SHA
    (HEAD / branch / tag)before checkout.
    Deterministic → enables caching (feat: Implement caching on a per-commit basis #343).
  • New pattern helpers
    utils.pattern_utils.process_patterns() centralises include/exclude parsing
    (moved out ofquery_parser). Adds thorough tests.
  • Windows-safe repo cleanup
    _handle_remove_readonly on-error callback makes read-only Git objects
    writable and retriesshutil.rmtree(), preventing WinError 5 in CI.
  • Public API cleanup (BREAKING)
    • parse_query()removed in favour of
      • parse_remote_repo() (URLs/slugs)
      • parse_local_dir_path() (local paths)
    • clone_repo,ingest_query,parse_query are no longer re-exported from
      gitingest.__init__.
  • Clone rewrite
    • Single entry point that always does: shallow clone → sparse-checkout
      (optional) → fetch commit → checkout → submodule update (optional).
    • _checkout_partial_clone renamed & moved →git_utils.checkout_partial_clone.
  • Server updates
    • query_processor uses new pattern utilities and passes a typed enum.
    • IngestRequest.validate_input_text() now removes any.git suffix.
  • Delete_is_safe_symlink
  • Remove pattern validation (delete_is_valid_pattern,InvalidPatternError, andtest_parse_patterns_invalid_characters)
  • Tests added/updated

    clone, pattern, parser, summary

File changes

gitingest

FileChanges
__init__.pyStop exposing internal helpers (clone_repo,ingest_query,parse_query)
clone.pyRewriteclone_repo to callresolve_commit, sparse checkout, and uniform fetch/checkout steps; move helper & rename
entrypoint.pyAdd_handle_remove_readonly callback for Windows temp-dir cleanup;ingest_async now usesparse_remote_repo /parse_local_dir_path
output_formatter.pyAdd missingTag prefix in_create_summary_prefix
query_parser.pyRemoveparse_query; move pattern helpers topattern_utils.py
utils/exceptions.pyDeleteInvalidPatternError
utils/git_utils.pyNewresolve_commit helper
utils/os_utils.pyRenameensure_directoryensure_directory_exists_or_create
utils/pattern_utils.pyConsolidated helpers +process_patterns
utils/query_parser_utils.pyDelete_is_valid_pattern
path_utils.py(removed)Delete obsolete helper_is_safe_symlink

server

FileChanges
models.pyStrip.git suffix invalidate_input_text
query_processor.pyReplaceparse_query withparse_remote_repo, integratePatternType, useprocess_patterns
routers_utils.pyCoercepattern_type intoPatternType enum

tests

FileChanges
conftest.pyAdjust fixtures
query_parser/test_git_host_agnostic.pySwitch toparse_remote_repo
query_parser/test_query_parser.pySwitch toparse_remote_repo; addparse_local_dir_path coverage
test_clone.pyUpdate expectations and fixtures
test_pattern_utils.pyAdd tests for_parse_patterns andprocess_patterns; removetest_parse_patterns_invalid_characters(pattern validation no longer enforced)
test_summary.pyVerify thatgitingest.ingest() emits correct summaries

@filipchristiansenfilipchristiansen changed the titleresolve commitfeat: resolve commitJul 9, 2025
@filipchristiansenfilipchristiansenforce-pushed theresolve-commit branch 3 times, most recently from7ab4af2 to831a36dCompareJuly 9, 2025 20:32
Copilot

This comment was marked as resolved.

@filipchristiansenfilipchristiansenforce-pushed theresolve-commit branch 6 times, most recently fromcf1aa6f tod1224a6CompareJuly 9, 2025 23:45
@filipchristiansenfilipchristiansen marked this pull request as ready for reviewJuly 9, 2025 23:47
Copilot

This comment was marked as resolved.

@filipchristiansenfilipchristiansenforce-pushed theresolve-commit branch 2 times, most recently from979c88a to3031e7cCompareJuly 10, 2025 00:07
@filipchristiansenfilipchristiansen changed the titlefeat: resolve commitrefactor: consistent cloning & pattern-handlingJul 10, 2025
@ix-56h

This comment was marked as resolved.

@filipchristiansen

This comment was marked as resolved.

Copy link
Contributor

@ix-56hix-56h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

filipchristiansen reacted with thumbs up emoji
@codecovCodecov

This comment was marked as off-topic.

if not await check_repo_exists(url, token=token):
msg = "Repository not found. Make sure it is public or that you have provided a valid token."
raise ValueError(msg)

commit = await resolve_commit(config, token=token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why not populate the CloneConfig directly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

My logic was that we should be able to reuse that after when manipulating the object

@NicolasIRAGNE

This comment was marked as duplicate.

@filipchristiansen
Copy link
ContributorAuthor

TODO:

  • delete_is_valid_pattern,InvalidPatternError,_is_safe_symlink
  • callresolve_commit inparse_remote_repo instead of inclone_repo

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@NicolasIRAGNENicolasIRAGNENicolasIRAGNE left review comments

Copilot code reviewCopilotCopilot left review comments

@ix-56hix-56hix-56h approved these changes

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

feat: avoid using branch references bug: Gitingest fetches entire repo for tagged subdirectories
3 participants
@filipchristiansen@ix-56h@NicolasIRAGNE

[8]ページ先頭

©2009-2025 Movatter.jp