gatsby-source-git
gatsby-source-git copied to clipboard
Override file modifiedTime by git commit history
Override the modifiedTime by git commit history.
- Add option "enableShallowClone" to enable/disable shallow clone
- When enableShallowClone is false, clone without "--depth 1" so that we can retrieve real commit time for a file
Hi @stevetweeddale ,
I do think so.
But the problem is, git does not record last modified time for a file. The only way(If I didn't get it wrong) is to get the timestramp for file latest commit.
In the README, you expects a shallow clone (git clone --depth 1) to speed up buidling a project. That makes sense. However, shallow commit lost all commit history.
The simple-git git.log(file)
method returns the latest commit for given file. If you do a shallow clone, it returns the the latest commit for the whole repository, instead of file.
// https://github.com/stevetweeddale/gatsby-source-git/pull/26/files#diff-a6f3904c41211be170d9b0eb87e49ea8d02d0fd5a7224d6772174b425dacf90fR109
const latest = log.latest;
const {date, message, author_name} = latest;
So, are you expecting to enable this feature by default, and have a longer git clone time? I'm open for any decision.
BR, Lawrence
Ah righto, I hadn't connected that a shallow clone doesn't give you accurate commit times. That is significant as the original project this plugin was written for had a big history including binary files so a full clone was prohibitively slow, and I can imagine other users needing the clones to be shallow.
However, I've got recollections of other pull requests that wanted a full checkout rather than shallow clone. It makes sense for there to be an option to switch between a full clone/shallow clone where necessary, though given Gatsby's emphasis on speed my instinct would still be for "fast by default", and only doing a full clone when necessary.
Hi @stevetweeddale ,
I updated my change, could you have a look when you have time? Thank you.
@stevetweeddale, hope you can grep a chance to merge, and publish the new package to NPM. Or would it be easier if to transfor the ownership as we discuss in this issue https://github.com/stevetweeddale/gatsby-source-git/issues/38?
I encountered this problem today - I'd love to see these changes merged!
Are any further changes required or is this good-to-go?
We should probably document this in the readme?
Finally I see some progress here. I will update my PR accordingly this week.
Test Evidence
-
fetchDepth is absent All files' modifiedTime is incorrect(the time of my latest commit)
-
fetchDepth is 0 modifiedTime and message reflect to correct commit
@darthsteven, good to merge?
Hi, any comment on this PR?
if no major concern on this change, I suggest we can merge this change into master. And leave the minor issues to another PR.
Another round of review&change may delay this change to 2024...