doc.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. Package hercules contains the functions which are needed to gather the line
  3. burndown statistics from a Git repository.
  4. Analyser is the main object which concentrates the high level logic. It
  5. provides Commits() and Analyse() methods to get the work done. The following
  6. example was taken from cmd/hercules:
  7. var repository *git.Repository
  8. // ... initialize repository ...
  9. analyser := hercules.Analyser{
  10. Repository: repository,
  11. OnProgress: func(commit, length int) {
  12. fmt.Fprintf(os.Stderr, "%d / %d\r", commit, length)
  13. },
  14. Granularity: 30,
  15. Sampling: 15,
  16. SimilarityThreshold: 90,
  17. Debug: false,
  18. }
  19. commits := analyser.Commits() // or specify a custom list
  20. statuses := analyser.Analyse(commits)
  21. // [y][x]int64 where y is the snapshot index and x is the granulated time index.
  22. As commented in the code, the list of commits can be any valid slice of *object.Commit.
  23. The returned statuses slice of slices is a rectangular 2D matrix where
  24. the number of rows equals to the repository's lifetime divided by the sampling
  25. value (detail factor) and the number of columns is the repository's lifetime
  26. divided by the granularity value (number of bands).
  27. Analyser depends heavily on https://github.com/src-d/go-git and leverages the
  28. diff algorithm through https://github.com/sergi/go-diff.
  29. Besides, hercules defines File and RBTree. These are low level data structures
  30. required by Analyser. File carries an instance of RBTree and the current line
  31. burndown state. RBTree implements the red-black balanced binary tree and is
  32. based on https://github.com/yasushi-saito/rbtree.
  33. */
  34. package hercules