MCPcopy Create free account
hub / github.com/go-git/go-git / Log

Method Log

repository.go:1239–1273  ·  view source on GitHub ↗

Log returns the commit history from the given LogOptions.

(o *LogOptions)

Source from the content-addressed store, hash-verified

1237
1238// Log returns the commit history from the given LogOptions.
1239func (r *Repository) Log(o *LogOptions) (object.CommitIter, error) {
1240 fn := commitIterFunc(o.Order)
1241 if fn == nil {
1242 return nil, fmt.Errorf("invalid Order=%v", o.Order)
1243 }
1244
1245 var (
1246 it object.CommitIter
1247 err error
1248 )
1249 if o.All {
1250 it, err = r.logAll(fn)
1251 } else {
1252 it, err = r.log(o.From, fn)
1253 }
1254
1255 if err != nil {
1256 return nil, err
1257 }
1258
1259 if o.FileName != nil {
1260 // for `git log --all` also check parent (if the next commit comes from the real parent)
1261 it = r.logWithFile(*o.FileName, it, o.All)
1262 }
1263 if o.PathFilter != nil {
1264 it = r.logWithPathFilter(o.PathFilter, it, o.All)
1265 }
1266
1267 if o.Since != nil || o.Until != nil {
1268 limitOptions := object.LogLimitOptions{Since: o.Since, Until: o.Until}
1269 it = r.logWithLimit(it, limitOptions)
1270 }
1271
1272 return it, nil
1273}
1274
1275func (r *Repository) log(from plumbing.Hash, commitIterFunc func(*object.Commit) object.CommitIter) (object.CommitIter, error) {
1276 h := from

Callers 15

TestCloneMirrorMethod · 0.80
TestLogMethod · 0.80
TestLogAllMethod · 0.80
TestLogAllOrderByTimeMethod · 0.80
TestLogHeadMethod · 0.80
TestLogErrorMethod · 0.80
TestLogFileNextMethod · 0.80
TestLogFileForEachMethod · 0.80
TestLogNonHeadFileMethod · 0.80
TestLogAllFileForEachMethod · 0.80

Calls 6

logAllMethod · 0.95
logMethod · 0.95
logWithFileMethod · 0.95
logWithPathFilterMethod · 0.95
logWithLimitMethod · 0.95
commitIterFuncFunction · 0.85

Tested by 15

TestCloneMirrorMethod · 0.64
TestLogMethod · 0.64
TestLogAllMethod · 0.64
TestLogAllOrderByTimeMethod · 0.64
TestLogHeadMethod · 0.64
TestLogErrorMethod · 0.64
TestLogFileNextMethod · 0.64
TestLogFileForEachMethod · 0.64
TestLogNonHeadFileMethod · 0.64
TestLogAllFileForEachMethod · 0.64