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.

commitgraph.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. package commitgraph
  2. import (
  3. "time"
  4. "github.com/go-git/go-git/v5/plumbing"
  5. )
  6. // CommitData is a reduced representation of Commit as presented in the commit graph
  7. // file. It is merely useful as an optimization for walking the commit graphs.
  8. type CommitData struct {
  9. // TreeHash is the hash of the root tree of the commit.
  10. TreeHash plumbing.Hash
  11. // ParentIndexes are the indexes of the parent commits of the commit.
  12. ParentIndexes []int
  13. // ParentHashes are the hashes of the parent commits of the commit.
  14. ParentHashes []plumbing.Hash
  15. // Generation number is the pre-computed generation in the commit graph
  16. // or zero if not available
  17. Generation int
  18. // When is the timestamp of the commit.
  19. When time.Time
  20. }
  21. // Index represents a representation of commit graph that allows indexed
  22. // access to the nodes using commit object hash
  23. type Index interface {
  24. // GetIndexByHash gets the index in the commit graph from commit hash, if available
  25. GetIndexByHash(h plumbing.Hash) (int, error)
  26. // GetNodeByIndex gets the commit node from the commit graph using index
  27. // obtained from child node, if available
  28. GetCommitDataByIndex(i int) (*CommitData, error)
  29. // Hashes returns all the hashes that are available in the index
  30. Hashes() []plumbing.Hash
  31. }