getGitMetadata breaks for files not yet commited
hamlim opened this issue · 3 comments
This is more of a pain point when working with mdxts
in development than anything else.
In my case I was adopting mdxts
within a Next + MDX blog app recently, and as part of that I was renaming some of my existing blog posts to debug the sources not being found (another quirk that I haven't revisited yet). Since I performed a normal mv old-path new-path
instead of a git mv old-path new-path
, the mdx
files weren't tracked via git, causing this code:
to result in lines
being an array of a single empty string:
lines = [ '' ]
(I added a console log to identify the issue)
This then throws an error later on when we call new Date()
on the value: https://github.com/souporserious/mdxts/blob/681c0677aba607a6283a161efa17a5da5f59cf77/packages/mdxts/src/utils/get-git-metadata.ts#L50
The error originates from these lines:
Ah, that makes sense. I recently added a check for shallow cloned repos so I can use that same logic since it will error if git isn't instantiated yet. I'll get this fixed up, thanks for flagging! As for the sources not being found, there might be a bug in the loader not picking up new/renamed files I'll take a look at.
Thanks for the really quick turnaround here!
Ok, got a chance to look into files not being updated locally and landed a fix. Hopefully, this fixes the issue you were running into! Also, just published a new release so these changes are available in 0.12.1 ✨