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

Adding Git Embeds and other improvements #29

Open
wants to merge 57 commits into
base: main
Choose a base branch
from

Conversation

qxprakash
Copy link


Key Features and Implementations:

1. Extended EmbedArgs:

Enhanced EmbedArgs to support five scenarios:

  • Git + Path: Clones the default branch and fetches the latest commit.
  • Git + Path + Branch: Clones a specified branch and fetches the latest commit.
  • Git + Path + Commit: Clones and checks out to a specific commit hash.
  • Git + Path + Tag: Clones and checks out to a specified tag.
  • Internal Nested Files: Previous flow intact

2. Improved Snippet Handling:

New Flow:

  • Entire files are now stored as snippets, enabling efficient parsing and embedding.
  • Supports embedding entire files directly when identifiers are not provided by the user.

Caching and Optimization:

  • Before cloning a repo, a unique file name is generated based on arguments (git, branch/tag/commit, path).
  • Snippets are saved in the .snippets directory.
  • File content hashes are compared with snippet hashes to prevent unnecessary updates.
  • Introduced DOCIFY_DISABLE_UPDATES to disable updates when unnecessary.

Edge Case Handling:

  • Added validation for file paths:
    • Prohibited paths starting with ../.
    • For Git URLs, paths starting with .. or / are forbidden.
  • Addressed Git URL edge cases by stripping .git suffixes to avoid hash mismatches.
  • Added helpful error messages for all edge cases.

let me know if any other changes are required.

With Regards
Prakash

…in that case throw an error that please pass the correct source file path
…h , still need to handle the case where both branch and commit hash is provided
…t , either one of commit , branch , tag can only be passed with git , also added validation check that none of tag , commit , branch be passed without specifying git argument
…, so in that case created snippet path without commit
…ck overflow error on the test

tests::embed_args_tests::test_token_stream_conversion_git
optimized function , to get refs of only the latest commit
@sam0x17
Copy link
Owner

sam0x17 commented Dec 16, 2024

this looks great, I will add docs and merge this shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants