本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 satır
487B

  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. }
上海开阖软件有限公司 沪ICP备12045867号-1