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

fix(transformer): find last modified date form commit on submodule #1831

Merged
merged 6 commits into from
Mar 19, 2025

Conversation

dralagen
Copy link
Contributor

@dralagen dralagen commented Mar 13, 2025

when the content folder has a submodule git, the relative path start in content folder and not root folder of quartz

example of repo use a submodule : https://github.com/dralagen/notes.dralagen.fr
The submodule is private to publish only public note and keep some private or draft not visible.

when the content folder has a submodule git, the relative path start in content folder and not root folder of quartz
@dralagen dralagen requested a review from jackyzha0 March 18, 2025 13:01
@jackyzha0
Copy link
Owner

can you see if 771110a works for you locally first?

@dralagen
Copy link
Contributor Author

dralagen commented Mar 18, 2025

can you see if 771110a works for you locally first?

I need to calculate the relative path from the repository.
In my case, ctx.argv.directory is equal to content folder, and file.data.filePath is equals to content/index.md.

if don't do modification, I have this result :

Warning: content/index.md isn't yet tracked by git, dates will be inaccurate

@@ -61,8 +62,9 @@ export const CreatedModifiedDate: QuartzTransformerPlugin<Partial<Options>> = (u
modified ||= file.data.frontmatter.modified as MaybeDate
published ||= file.data.frontmatter.published as MaybeDate
} else if (source === "git" && repo) {
const relativePath = path.relative(repo.workdir()!, fullFp)
Copy link
Owner

Choose a reason for hiding this comment

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

calculate workdir where we assign repo and also add an error for when workdir is undefined

Copy link
Contributor Author

@dralagen dralagen Mar 18, 2025

Choose a reason for hiding this comment

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

workdir return undefined if repository is bare. I thinks, we have other problem on build, like don't find index.md.

calculate workdir where we assign repo

You want to set the value of repo.workdir() to variable ?

Copy link
Owner

Choose a reason for hiding this comment

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

yes because path.relative(undefined, fullFp) will cause problems

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thanks for review.

use default value if repo.workdir is undefined to user fullFp value
if (opts.priority.includes("git")) {
try {
repo = Repository.discover(ctx.argv.directory)
repositoryWorkdir = repo.workdir() ?? ""
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
repositoryWorkdir = repo.workdir() ?? ""
repositoryWorkdir = repo.workdir() ?? ctx.argv.directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't use ctx.argv.directory as default value, because the major usage is the root folder is the workdir of repository and ctx.argc.directory is valued to content.
I want to set a default value to make path.relative(repositoryWorkdir, fullFp) equals to fullFp

@jackyzha0 jackyzha0 merged commit bcde2ab into jackyzha0:v4 Mar 19, 2025
5 checks passed
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