Skip to content

Commit

Permalink
Make failed authors parsing to not stop tree build
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuswilms committed Mar 30, 2018
1 parent b9b17ef commit f85647e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions author.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main

import (
"bufio"
"fmt"
"io"
"os"
"strings"
Expand Down Expand Up @@ -65,6 +66,9 @@ func (as Authors) parse(r io.Reader) ([]*Author, error) {
continue
}
beginMail := strings.Index(line, "<")
if beginMail == -1 {
return parsed, fmt.Errorf("expected angle bracket in line '%s'", line)
}

name := strings.TrimSpace(line[0 : beginMail-1])
email := strings.TrimSpace(line[beginMail+1 : len(line)-1])
Expand Down
4 changes: 3 additions & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"strings"
"sync"
"time"

"github.com/fatih/color"
)

var (
Expand Down Expand Up @@ -55,7 +57,7 @@ func NewNode(path string, root string) *Node {
}

if err := n.loadMeta(); err != nil {
log.Print(err)
log.Print(color.New(color.FgYellow).Sprint(err))
}
return n
}
Expand Down
5 changes: 4 additions & 1 deletion node_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"strings"
"sync"
"time"

"github.com/fatih/color"
)

var (
Expand Down Expand Up @@ -128,7 +130,8 @@ func (t *NodeTree) Sync() error {
if _, err := os.Stat(authorsFile); err == nil {
as, err = NewAuthorsFromFile(authorsFile)
if err != nil {
return err
log.Print(color.New(color.FgYellow).Sprintf("Failed parsing %s: %s", prettyPath(authorsFile), err))
as = &Authors{}
}
} else {
as = &Authors{}
Expand Down

0 comments on commit f85647e

Please sign in to comment.