improve enrichment, fix git normalization

pull/123/head
Simon Let 6 years ago
parent 14611c87c9
commit 4d3a6fd1c4
  1. 3
      cmd/cli/item.go
  2. 16
      pkg/records/records.go

@ -202,6 +202,9 @@ func newItemFromRecordForQuery(record records.EnrichedRecord, query query, debug
flags += " E" + strconv.Itoa(record.ExitCode) flags += " E" + strconv.Itoa(record.ExitCode)
flagsWithColor += " " + highlightWarn("E"+strconv.Itoa(record.ExitCode)) flagsWithColor += " " + highlightWarn("E"+strconv.Itoa(record.ExitCode))
} }
// NOTE: you can debug arbitrary metadata like this
// flags += " <" + record.GitOriginRemote + ">"
// flagsWithColor += " <" + record.GitOriginRemote + ">"
// DISPLAY > cmdline // DISPLAY > cmdline

@ -169,26 +169,26 @@ func (r EnrichedRecord) ToString() (string, error) {
// Enriched - returnd enriched record // Enriched - returnd enriched record
func Enriched(r Record) EnrichedRecord { func Enriched(r Record) EnrichedRecord {
record := EnrichedRecord{Record: r} record := EnrichedRecord{Record: r}
// normlize git remote
record.GitOriginRemote = NormalizeGitRemote(record.GitOriginRemote)
record.GitOriginRemoteAfter = NormalizeGitRemote(record.GitOriginRemoteAfter)
// Get command/first word from commandline // Get command/first word from commandline
var err error var err error
record.Command, record.FirstWord, err = GetCommandAndFirstWord(r.CmdLine) err = r.Validate()
if err != nil { if err != nil {
record.Errors = append(record.Errors, "GetCommandAndFirstWord error:"+err.Error()) record.Errors = append(record.Errors, "Validate error:"+err.Error())
// rec, _ := record.ToString() // rec, _ := record.ToString()
// log.Println("Invalid command:", rec) // log.Println("Invalid command:", rec)
record.Invalid = true record.Invalid = true
return record
} }
err = r.Validate() record.Command, record.FirstWord, err = GetCommandAndFirstWord(r.CmdLine)
if err != nil { if err != nil {
record.Errors = append(record.Errors, "Validate error:"+err.Error()) record.Errors = append(record.Errors, "GetCommandAndFirstWord error:"+err.Error())
// rec, _ := record.ToString() // rec, _ := record.ToString()
// log.Println("Invalid command:", rec) // log.Println("Invalid command:", rec)
record.Invalid = true record.Invalid = true // should this be really invalid ?
} }
record.GitOriginRemote = NormalizeGitRemote(record.GitOriginRemote)
return record return record
// TODO: Detect and mark simple commands r.Simple
} }
// Merge two records (part1 - collect + part2 - postcollect) // Merge two records (part1 - collect + part2 - postcollect)

Loading…
Cancel
Save