File: path.go

package info (click to toggle)
git-lfs 2.7.1-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,976 kB
  • sloc: sh: 13,903; makefile: 333; ruby: 100
file content (35 lines) | stat: -rw-r--r-- 838 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package commands

import "strings"

func gitLineEnding(git env) string {
	value, _ := git.Get("core.autocrlf")
	switch strings.ToLower(value) {
	case "input", "true", "t", "1":
		return "\r\n"
	default:
		return osLineEnding()
	}
}

const (
	windowsPrefix = `.\`
	nixPrefix     = `./`
)

// trimCurrentPrefix removes a leading prefix of "./" or ".\" (referring to the
// current directory in a platform independent manner).
//
// It is useful for callers such as "git lfs track" and "git lfs untrack", that
// wish to compare filepaths and/or attributes patterns without cleaning across
// multiple platforms.
func trimCurrentPrefix(p string) string {
	if strings.HasPrefix(p, windowsPrefix) {
		return strings.TrimPrefix(p, windowsPrefix)
	}
	return strings.TrimPrefix(p, nixPrefix)
}

type env interface {
	Get(string) (string, bool)
}