|
@@ -18,9 +18,8 @@ import (
|
|
// CommitsAnalysis extracts statistics for each commit
|
|
// CommitsAnalysis extracts statistics for each commit
|
|
type CommitsAnalysis struct {
|
|
type CommitsAnalysis struct {
|
|
core.NoopMerger
|
|
core.NoopMerger
|
|
- core.OneShotMergeProcessor
|
|
|
|
|
|
|
|
- // days maps days to developers to stats
|
|
|
|
|
|
+ // commits stores statistics for each commit
|
|
commits []*CommitStat
|
|
commits []*CommitStat
|
|
// reversedPeopleDict references IdentityDetector.ReversedPeopleDict
|
|
// reversedPeopleDict references IdentityDetector.ReversedPeopleDict
|
|
reversedPeopleDict []string
|
|
reversedPeopleDict []string
|
|
@@ -35,7 +34,7 @@ type CommitsResult struct {
|
|
reversedPeopleDict []string
|
|
reversedPeopleDict []string
|
|
}
|
|
}
|
|
|
|
|
|
-// FileStat is a statistic for a file
|
|
|
|
|
|
+// FileStat is the statistics for a file in a commit
|
|
type FileStat struct {
|
|
type FileStat struct {
|
|
Name string
|
|
Name string
|
|
Language string
|
|
Language string
|
|
@@ -91,13 +90,12 @@ func (ca *CommitsAnalysis) Flag() string {
|
|
|
|
|
|
// Description returns the text which explains what the analysis is doing.
|
|
// Description returns the text which explains what the analysis is doing.
|
|
func (ca *CommitsAnalysis) Description() string {
|
|
func (ca *CommitsAnalysis) Description() string {
|
|
- return "Extracts statistics for each commit."
|
|
|
|
|
|
+ return "Extracts statistics for each commit. Identical to `git log --stat`"
|
|
}
|
|
}
|
|
|
|
|
|
// Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume()
|
|
// Initialize resets the temporary caches and prepares this PipelineItem for a series of Consume()
|
|
// calls. The repository which is going to be analysed is supplied as an argument.
|
|
// calls. The repository which is going to be analysed is supplied as an argument.
|
|
func (ca *CommitsAnalysis) Initialize(repository *git.Repository) error {
|
|
func (ca *CommitsAnalysis) Initialize(repository *git.Repository) error {
|
|
- ca.OneShotMergeProcessor.Initialize()
|
|
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,24 +105,18 @@ func (ca *CommitsAnalysis) Initialize(repository *git.Repository) error {
|
|
// This function returns the mapping with analysis results. The keys must be the same as
|
|
// This function returns the mapping with analysis results. The keys must be the same as
|
|
// in Provides(). If there was an error, nil is returned.
|
|
// in Provides(). If there was an error, nil is returned.
|
|
func (ca *CommitsAnalysis) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
|
|
func (ca *CommitsAnalysis) Consume(deps map[string]interface{}) (map[string]interface{}, error) {
|
|
- if !ca.ShouldConsumeCommit(deps) {
|
|
|
|
- return nil, nil
|
|
|
|
- }
|
|
|
|
if deps[core.DependencyIsMerge].(bool) {
|
|
if deps[core.DependencyIsMerge].(bool) {
|
|
return nil, nil
|
|
return nil, nil
|
|
}
|
|
}
|
|
-
|
|
|
|
commit := deps[core.DependencyCommit].(*object.Commit)
|
|
commit := deps[core.DependencyCommit].(*object.Commit)
|
|
author := deps[identity.DependencyAuthor].(int)
|
|
author := deps[identity.DependencyAuthor].(int)
|
|
lineStats := deps[items.DependencyLineStats].(map[object.ChangeEntry]items.LineStats)
|
|
lineStats := deps[items.DependencyLineStats].(map[object.ChangeEntry]items.LineStats)
|
|
langs := deps[items.DependencyLanguages].(map[plumbing.Hash]string)
|
|
langs := deps[items.DependencyLanguages].(map[plumbing.Hash]string)
|
|
-
|
|
|
|
cs := CommitStat{
|
|
cs := CommitStat{
|
|
Hash: commit.Hash.String(),
|
|
Hash: commit.Hash.String(),
|
|
When: commit.Author.When.Unix(),
|
|
When: commit.Author.When.Unix(),
|
|
Author: author,
|
|
Author: author,
|
|
}
|
|
}
|
|
-
|
|
|
|
for entry, stats := range lineStats {
|
|
for entry, stats := range lineStats {
|
|
cs.Files = append(cs.Files, FileStat{
|
|
cs.Files = append(cs.Files, FileStat{
|
|
Name: entry.Name,
|
|
Name: entry.Name,
|
|
@@ -132,9 +124,7 @@ func (ca *CommitsAnalysis) Consume(deps map[string]interface{}) (map[string]inte
|
|
LineStats: stats,
|
|
LineStats: stats,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
-
|
|
|
|
ca.commits = append(ca.commits, &cs)
|
|
ca.commits = append(ca.commits, &cs)
|
|
-
|
|
|
|
return nil, nil
|
|
return nil, nil
|
|
}
|
|
}
|
|
|
|
|
|
@@ -162,16 +152,6 @@ func (ca *CommitsAnalysis) Serialize(result interface{}, binary bool, writer io.
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-// Deserialize converts the specified protobuf bytes to DevsResult.
|
|
|
|
-func (ca *CommitsAnalysis) Deserialize(pbmessage []byte) (interface{}, error) {
|
|
|
|
- panic("not implemented")
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// MergeResults combines two DevsAnalysis-es together.
|
|
|
|
-func (ca *CommitsAnalysis) MergeResults(r1, r2 interface{}, c1, c2 *core.CommonAnalysisResult) interface{} {
|
|
|
|
- panic("not implemented")
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func (ca *CommitsAnalysis) serializeText(result *CommitsResult, writer io.Writer) {
|
|
func (ca *CommitsAnalysis) serializeText(result *CommitsResult, writer io.Writer) {
|
|
fmt.Fprintln(writer, " commits:")
|
|
fmt.Fprintln(writer, " commits:")
|
|
for _, c := range result.Commits {
|
|
for _, c := range result.Commits {
|