How to get the latest commit only by path?
Description
Hi guys, I want to get the latest commit of specific path and it should be equal to below command:
git log -n 1 --pretty=format:%H -- path/to/folderOrFile
I try to get the log by g.Log as showed in this example:
https://github.com/go-git/go-git/blob/da810275bf682d29a530ed819aff175f47bd7634/_examples/log/main.go#L18-L47
But now it seems LogOptions don't support -n argument.
Any idea about it?
Thx
Could we add -n arguments in ListOptions?
You can get just one commit with:
commit, err := cIter.Next()
cIter.Close()
You can get just one commit with:
commit, err := cIter.Next() cIter.Close()
FYI what I want actually is that the cIter just store the latest commit like -n 1 do.
The ability to find the latest commit of a specific file is impacted by https://github.com/go-git/go-git/issues/811 on projects with sizeable commit history.
To help us keep things tidy and focus on the active tasks, we've introduced a stale bot to spot issues/PRs that haven't had any activity in a while.
This particular issue hasn't had any updates or activity in the past 90 days, so it's been labeled as 'stale'. If it remains inactive for the next 30 days, it'll be automatically closed.
We understand everyone's busy, but if this issue is still important to you, please feel free to add a comment or make an update to keep it active.
Thanks for your understanding and cooperation!