doc.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. Package hercules contains the functions which are needed to gather various statistics
  3. from a Git repository.
  4. The analysis is expressed in a form of the tree: there are nodes - "pipeline items" - which
  5. require some other nodes to be executed prior to selves and in turn provide the data for
  6. dependent nodes. There are several service items which do not produce any useful
  7. statistics but rather provide the requirements for other items. The top-level items
  8. include:
  9. - BurndownAnalysis - line burndown statistics for project, files and developers.
  10. - CouplesAnalysis - coupling statistics for files and developers.
  11. The typical API usage is to initialize the Pipeline class:
  12. import "gopkg.in/src-d/go-git.v4"
  13. var repository *git.Repository
  14. // ...initialize repository...
  15. pipeline := hercules.NewPipeline(repository)
  16. Then add the required analysis:
  17. ba := pipeline.DeployItem(&hercules.BurndownAnalysis{
  18. Granularity: 30,
  19. Sampling: 30,
  20. }).(hercules.LeafPipelineItem)
  21. This call will add all the needed intermediate pipeline items. Then link and execute the analysis tree:
  22. pipeline.Initialize(nil)
  23. result, err := pipeline.Run(pipeline.Commits())
  24. Finally extract the result:
  25. result := result[ba].(hercules.BurndownResult)
  26. The actual usage example is cmd/hercules/main.go - the command line tool's code.
  27. Hercules 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 BurndownAnalysis. 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. Coupling stats are supposed to be further processed rather than observed directly.
  34. labours.py uses Swivel embeddings and visualises them in Tensorflow Projector.
  35. */
  36. package hercules