Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

common.go 487B

12345678910111213141516171819202122
  1. package git
  2. import "strings"
  3. const defaultDotGitPath = ".git"
  4. // countLines returns the number of lines in a string à la git, this is
  5. // The newline character is assumed to be '\n'. The empty string
  6. // contains 0 lines. If the last line of the string doesn't end with a
  7. // newline, it will still be considered a line.
  8. func countLines(s string) int {
  9. if s == "" {
  10. return 0
  11. }
  12. nEOL := strings.Count(s, "\n")
  13. if strings.HasSuffix(s, "\n") {
  14. return nEOL
  15. }
  16. return nEOL + 1
  17. }