From b9068fc0dc2a583dbd68fad4d4282e5b9e38c1fe Mon Sep 17 00:00:00 2001 From: Philip Colmer Date: Wed, 18 Sep 2024 14:44:20 +0100 Subject: [PATCH 1/4] Apply fix to git log command --- src/pages/applications/[...slug].astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/applications/[...slug].astro b/src/pages/applications/[...slug].astro index dd99eeba..18978b87 100644 --- a/src/pages/applications/[...slug].astro +++ b/src/pages/applications/[...slug].astro @@ -33,7 +33,7 @@ if (!import.meta.env.IS_PUBLIC) { project = Astro.props; try { const { stdout } = await execAsync( - `git log -1 --pretty="format:%ci" ${process.cwd()}/src/content/applications/${slug}.md` + `git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/applications/${slug}.md"` ); date = new Date(stdout); } catch (e) { From bdea25d8f958dfb58ece483a2ef9b8d47694fec7 Mon Sep 17 00:00:00 2001 From: Philip Colmer Date: Wed, 18 Sep 2024 15:01:40 +0100 Subject: [PATCH 2/4] Tweak date retrieval again --- src/pages/applications/[...slug].astro | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/applications/[...slug].astro b/src/pages/applications/[...slug].astro index 18978b87..bd9b74af 100644 --- a/src/pages/applications/[...slug].astro +++ b/src/pages/applications/[...slug].astro @@ -33,8 +33,11 @@ if (!import.meta.env.IS_PUBLIC) { project = Astro.props; try { const { stdout } = await execAsync( - `git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/applications/${slug}.md"` + `git log -1 --pretty="format:%ci" src/content/applications/${slug}.md` ); + if (stdout == "") { + throw new Error(`Failed to retrieve date for ${slug}.md`); + } date = new Date(stdout); } catch (e) { throw new Error(`Failed to parse date for ${slug}.md.\n${e}`); From 19e5365cfafae2800a83a56d3870c84379ac3b30 Mon Sep 17 00:00:00 2001 From: Philip Colmer Date: Wed, 18 Sep 2024 15:21:01 +0100 Subject: [PATCH 3/4] Use the correct Astro attribute for case sensitivity --- src/pages/applications/[...slug].astro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/applications/[...slug].astro b/src/pages/applications/[...slug].astro index bd9b74af..f44424ed 100644 --- a/src/pages/applications/[...slug].astro +++ b/src/pages/applications/[...slug].astro @@ -33,14 +33,14 @@ if (!import.meta.env.IS_PUBLIC) { project = Astro.props; try { const { stdout } = await execAsync( - `git log -1 --pretty="format:%ci" src/content/applications/${slug}.md` + `git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/applications/${project.id}.md"` ); if (stdout == "") { - throw new Error(`Failed to retrieve date for ${slug}.md`); + throw new Error(`Failed to retrieve date for ${project.id}.md`); } date = new Date(stdout); } catch (e) { - throw new Error(`Failed to parse date for ${slug}.md.\n${e}`); + throw new Error(`Failed to parse date for ${project.id}.md.\n${e}`); } } --- From 103fedbb063dd48a7851e635e0e7beb2ef58473a Mon Sep 17 00:00:00 2001 From: Philip Colmer Date: Wed, 18 Sep 2024 15:32:23 +0100 Subject: [PATCH 4/4] Fix typo --- src/pages/applications/[...slug].astro | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/applications/[...slug].astro b/src/pages/applications/[...slug].astro index f44424ed..bfa88df0 100644 --- a/src/pages/applications/[...slug].astro +++ b/src/pages/applications/[...slug].astro @@ -33,14 +33,14 @@ if (!import.meta.env.IS_PUBLIC) { project = Astro.props; try { const { stdout } = await execAsync( - `git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/applications/${project.id}.md"` + `git log -1 --pretty="format:%ci" -- "${process.cwd()}/src/content/applications/${project.id}"` ); if (stdout == "") { - throw new Error(`Failed to retrieve date for ${project.id}.md`); + throw new Error(`Failed to retrieve date for ${project.id}`); } date = new Date(stdout); } catch (e) { - throw new Error(`Failed to parse date for ${project.id}.md.\n${e}`); + throw new Error(`Failed to parse date for ${project.id}\n${e}`); } } ---