1 package mappers 2 3 import ( 4 "fmt" 5 c "repodiff/constants" 6 e "repodiff/entities" 7 ) 8 9 func CommitCSVHeader() []string { 10 return []string{ 11 "Date", 12 "Commit", 13 "Downstream Project", 14 "Author", 15 "Subject", 16 "Project Type", 17 } 18 } 19 20 func 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 33 func 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 42 func 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