本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 line
979B

  1. // Copyright 2019 The Gitea Authors.
  2. // All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package git
  6. import (
  7. "os"
  8. "path"
  9. gitealog "code.gitea.io/gitea/modules/log"
  10. "gopkg.in/src-d/go-git.v4/plumbing/format/commitgraph"
  11. cgobject "gopkg.in/src-d/go-git.v4/plumbing/object/commitgraph"
  12. )
  13. // CommitNodeIndex returns the index for walking commit graph
  14. func (r *Repository) CommitNodeIndex() (cgobject.CommitNodeIndex, *os.File) {
  15. indexPath := path.Join(r.Path, "objects", "info", "commit-graph")
  16. file, err := os.Open(indexPath)
  17. if err == nil {
  18. var index commitgraph.Index
  19. index, err = commitgraph.OpenFileIndex(file)
  20. if err == nil {
  21. return cgobject.NewGraphCommitNodeIndex(index, r.gogitRepo.Storer), file
  22. }
  23. }
  24. if !os.IsNotExist(err) {
  25. gitealog.Warn("Unable to read commit-graph for %s: %v", r.Path, err)
  26. }
  27. return cgobject.NewObjectCommitNodeIndex(r.gogitRepo.Storer), nil
  28. }
上海开阖软件有限公司 沪ICP备12045867号-1