• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package mappers
2
3import (
4	"fmt"
5	c "repodiff/constants"
6	e "repodiff/entities"
7)
8
9func CommitCSVHeader() []string {
10	return []string{
11		"Date",
12		"Commit",
13		"Downstream Project",
14		"Author",
15		"Subject",
16		"Project Type",
17	}
18}
19
20func CommitEntityToCSVRow(a e.AnalyzedCommitRow) []string {
21	return quoteAll(
22		[]string{
23			a.Date,
24			a.Commit,
25			a.DownstreamProject,
26			a.Author,
27			a.Subject,
28			c.ProjectTypeToDisplay[a.Type],
29		},
30	)
31}
32
33func CommitEntitiesToCSVRows(commits []e.AnalyzedCommitRow) [][]string {
34	rowsOfCols := make([][]string, len(commits))
35	for i, commit := range commits {
36		cols := CommitEntityToCSVRow(commit)
37		rowsOfCols[i] = cols
38	}
39	return rowsOfCols
40}
41
42func quoteAll(s []string) []string {
43	copied := make([]string, len(s))
44	for i, val := range s {
45		copied[i] = fmt.Sprintf("%q", val)
46	}
47	return copied
48}
49