Skip to content

Commit

Permalink
Move sanitiseLine function (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmenezes authored Jul 24, 2020
1 parent fc2fc0a commit 8a95900
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 9 additions & 0 deletions codeowners.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ import (
// DefaultLocations provides default locations for the CODEOWNERS file
var DefaultLocations = [...]string{"CODEOWNERS", "docs/CODEOWNERS", ".github/CODEOWNERS"}

// sanitiseLine removes all empty space and comments from a given line
func sanitiseLine(line string) string {
i := strings.Index(line, "#")
if i >= 0 {
line = line[:i]
}
return strings.Trim(line, " ")
}

// ParseLine parses a CODEOWNERS line into file pattern and owners
func ParseLine(line string) (string, []string) {
line = sanitiseLine(line)
Expand Down
10 changes: 0 additions & 10 deletions decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package codeowners
import (
"bufio"
"io"
"strings"
)

// Decoder providers functionality to read CODEOWNERS data
Expand Down Expand Up @@ -39,15 +38,6 @@ func (d *Decoder) peek() {
}
}

// sanitiseLine removes all empty space and comments from a given line
func sanitiseLine(line string) string {
i := strings.Index(line, "#")
if i >= 0 {
line = line[:i]
}
return strings.Trim(line, " ")
}

// More returns true if there are available CODEOWNERS lines to be scanned.
// And also advances to the next line.
func (d *Decoder) More() bool {
Expand Down

0 comments on commit 8a95900

Please sign in to comment.