This commit is contained in:
zricethezav committed 2018-02-22 11:36:23 -06:00
1 parent 4137d3cfc0
commit 744ff2f876
382 files changed
+94483

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
package git
import "strings"
const defaultDotGitPath = ".git"
// countLines returns the number of lines in a string à la git, this is
// The newline character is assumed to be '\n'. The empty string
// contains 0 lines. If the last line of the string doesn't end with a
// newline, it will still be considered a line.
func countLines(s string) int {
if s == "" {
return 0
}
nEOL := strings.Count(s, "\n")
if strings.HasSuffix(s, "\n") {
return nEOL
}
return nEOL + 1
}