Files
android_development/tools/repo_diff/service/repodiff/mappers/csv.go
Scott Lobdell dbbd386111 Add command-line functionality for versatile usage of repodiff service.
Reporting is another use case that should be satisfied by this tool.
Since the use case deviates in terms of I/O, it's worth adding a
command-line interface for now and for future expansion.

Test: Unit tests included, will validate locally
Change-Id: Ifade560d9898722fdd5299d06899265b70ce771f
2018-05-02 08:56:48 -07:00

49 lines
834 B
Go

package mappers
import (
"fmt"
c "repodiff/constants"
e "repodiff/entities"
)
func CommitCSVHeader() []string {
return []string{
"Date",
"Commit",
"Downstream Project",
"Author",
"Subject",
"Project Type",
}
}
func CommitEntityToCSVRow(a e.AnalyzedCommitRow) []string {
return quoteAll(
[]string{
a.Date,
a.Commit,
a.DownstreamProject,
a.Author,
a.Subject,
c.ProjectTypeToDisplay[a.Type],
},
)
}
func CommitEntitiesToCSVRows(commits []e.AnalyzedCommitRow) [][]string {
rowsOfCols := make([][]string, len(commits))
for i, commit := range commits {
cols := CommitEntityToCSVRow(commit)
rowsOfCols[i] = cols
}
return rowsOfCols
}
func quoteAll(s []string) []string {
copied := make([]string, len(s))
for i, val := range s {
copied[i] = fmt.Sprintf("%q", val)
}
return copied
}