Skip to content

Commit

Permalink
Merge pull request #667 from weakish/git-created-date
Browse files Browse the repository at this point in the history
fallback to git last modified upon empty git created date
  • Loading branch information
oscarotero authored Sep 27, 2024
2 parents ccddaa6 + a00da5f commit 2d75fa2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Go to the `v1` branch to see the changelog of Lume 1.
### Added
- Basic auth middleware: Added `errorMessage` option.
### Fixed
- When using special value `git created` for `date` variable, it will fall back to `git modified` first, then filesystem last modified date.
- Updated dependencies: `linkedom`, `sass`, `satori`, `terser`, `liquidjs`, `tailwind`, `date-fns`, `std`, `esbuild`, `preact`, `lightningcss`, `postcss`, `remark-rehype`, `react` types, `unocss`.

## [2.3.2] - 2024-09-10
Expand Down
7 changes: 6 additions & 1 deletion core/utils/page_date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export function getPageDate(page: Page): Date {
case "git last modified":
return getGitDate("modified", entry.src) || info.mtime || new Date();
case "git created":
return getGitDate("created", entry.src) || info.birthtime ||
// getGitDate("created", ...) uses `git log --diff-filter=A`
// which returns nothing for files where the latest commit had a merge conflict.
// Therefore we fallback to last modified time from git history,
// which is more reliable than file system creation time under most CI environments.
return getGitDate("created", entry.src) ||
getGitDate("modified", entry.src) || info.birthtime ||
new Date();
}
}
Expand Down

0 comments on commit 2d75fa2

Please sign in to comment.