core.go 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package hercules
  2. import (
  3. git "gopkg.in/src-d/go-git.v4"
  4. "gopkg.in/src-d/go-git.v4/plumbing/object"
  5. "gopkg.in/src-d/hercules.v4/internal/core"
  6. "gopkg.in/src-d/hercules.v4/leaves"
  7. )
  8. // ConfigurationOptionType represents the possible types of a ConfigurationOption's value.
  9. type ConfigurationOptionType = core.ConfigurationOptionType
  10. const (
  11. // BoolConfigurationOption reflects the boolean value type.
  12. BoolConfigurationOption = core.BoolConfigurationOption
  13. // IntConfigurationOption reflects the integer value type.
  14. IntConfigurationOption = core.IntConfigurationOption
  15. // StringConfigurationOption reflects the string value type.
  16. StringConfigurationOption = core.StringConfigurationOption
  17. // FloatConfigurationOption reflects a floating point value type.
  18. FloatConfigurationOption = core.FloatConfigurationOption
  19. // StringsConfigurationOption reflects the array of strings value type.
  20. StringsConfigurationOption = core.StringsConfigurationOption
  21. )
  22. // ConfigurationOption allows for the unified, retrospective way to setup PipelineItem-s.
  23. type ConfigurationOption = core.ConfigurationOption
  24. // PipelineItem is the interface for all the units in the Git commits analysis pipeline.
  25. type PipelineItem = core.PipelineItem
  26. // FeaturedPipelineItem enables switching the automatic insertion of pipeline items on or off.
  27. type FeaturedPipelineItem = core.FeaturedPipelineItem
  28. // LeafPipelineItem corresponds to the top level pipeline items which produce the end results.
  29. type LeafPipelineItem = core.LeafPipelineItem
  30. // MergeablePipelineItem specifies the methods to combine several analysis results together.
  31. type MergeablePipelineItem = core.MergeablePipelineItem
  32. // CommonAnalysisResult holds the information which is always extracted at Pipeline.Run().
  33. type CommonAnalysisResult = core.CommonAnalysisResult
  34. // MetadataToCommonAnalysisResult copies the data from a Protobuf message.
  35. func MetadataToCommonAnalysisResult(meta *core.Metadata) *CommonAnalysisResult {
  36. return core.MetadataToCommonAnalysisResult(meta)
  37. }
  38. // Pipeline is the core Hercules entity which carries several PipelineItems and executes them.
  39. // See the extended example of how a Pipeline works in doc.go
  40. type Pipeline = core.Pipeline
  41. const (
  42. // ConfigPipelineDumpPath is the name of the Pipeline configuration option (Pipeline.Initialize())
  43. // which enables saving the items DAG to the specified file.
  44. ConfigPipelineDumpPath = core.ConfigPipelineDumpPath
  45. // ConfigPipelineDryRun is the name of the Pipeline configuration option (Pipeline.Initialize())
  46. // which disables Configure() and Initialize() invocation on each PipelineItem during the
  47. // Pipeline initialization.
  48. // Subsequent Run() calls are going to fail. Useful with ConfigPipelineDumpPath=true.
  49. ConfigPipelineDryRun = core.ConfigPipelineDryRun
  50. // ConfigPipelineCommits is the name of the Pipeline configuration option (Pipeline.Initialize())
  51. // which allows to specify the custom commit sequence. By default, Pipeline.Commits() is used.
  52. ConfigPipelineCommits = core.ConfigPipelineCommits
  53. )
  54. // NewPipeline initializes a new instance of Pipeline struct.
  55. func NewPipeline(repository *git.Repository) *Pipeline {
  56. return core.NewPipeline(repository)
  57. }
  58. // LoadCommitsFromFile reads the file by the specified FS path and generates the sequence of commits
  59. // by interpreting each line as a Git commit hash.
  60. func LoadCommitsFromFile(path string, repository *git.Repository) ([]*object.Commit, error) {
  61. return core.LoadCommitsFromFile(path, repository)
  62. }
  63. // PipelineItemRegistry contains all the known PipelineItem-s.
  64. type PipelineItemRegistry = core.PipelineItemRegistry
  65. // Registry contains all known pipeline item types.
  66. var Registry = core.Registry
  67. func init() {
  68. // hack to link with .leaves
  69. _ = leaves.BurndownAnalysis{}
  70. }