Debian Codegraph @

tools/filetools_test.go

raw symbols SCIP
1 package toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
5 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
6 "os/userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/"
7 "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/"
8 "runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/"
9 "sortscip-go gomod github.com/golang/go/src go1.25.0 sort/"
10 "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/"
11
12 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
13 )
14
15 func TestCleanPathsCleansPathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestCleanPathsCleansPaths().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
16 cleaned := CleanPathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CleanPaths().("/foo/bar/,/foo/bar/baz", ",")
17 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, []string{"/foo/bar", "/foo/bar/baz"}, cleaned)
18 }
19
20 func TestCleanPathsReturnsNoResultsWhenGivenNoPathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestCleanPathsReturnsNoResultsWhenGivenNoPaths().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
21 cleaned := CleanPathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CleanPaths().("", ",")
22 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Emptyscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Empty().(t, cleaned)
23 }
24
25 type ExpandPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase# struct {
26 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path. string
27 Expandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Expand. bool
28
29 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want. string
30 WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#WantErr. string
31
32 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser. func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error)
33 lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser. func(who string) (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error)
34 }
35
36 func (c *ExpandPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#) Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Assert().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
37 if c.currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser. != nil {
38 oldCurrentUser := currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser.
39 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser. = c.currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser.
40 defer func() { currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser. = oldCurrentUser }()
41 }
42
43 if c.lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser. != nil {
44 oldLookupUser := lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupUser.
45 lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupUser. = c.lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser.
46 defer func() { lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupUser. = oldLookupUser }()
47 }
48
49 got, err := ExpandPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPath().(c.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path., c.Expandscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Expand.)
50 if err != nil || len(c.WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#WantErr.) > 0 {
51 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, c.WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#WantErr.)
52 }
53 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/ToSlash().(c.Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.), filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/ToSlash().(got))
54 }
55
56 func TestExpandPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestExpandPath().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
57 for desc, c := range map[string]*ExpandPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#{
58 "no expand": {
59 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "/path/to/hooks",
60 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/path/to/hooks",
61 },
62 "current": {
63 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~/path/to/hooks",
64 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/home/jane/path/to/hooks",
65 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser.: func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
66 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
67 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/jane",
68 }, nil
69 },
70 },
71 "current, slash": {
72 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~/",
73 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/home/jane",
74 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser.: func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
75 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
76 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/jane",
77 }, nil
78 },
79 },
80 "current, no slash": {
81 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~",
82 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/home/jane",
83 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#currentUser.: func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
84 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
85 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/jane",
86 }, nil
87 },
88 },
89 "non-current": {
90 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~other/path/to/hooks",
91 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/home/special/path/to/hooks",
92 lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser.: func(who string) (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
93 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "other", who)
94 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
95 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/special",
96 }, nil
97 },
98 },
99 "non-current, no slash": {
100 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~other",
101 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Want.: "/home/special",
102 lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser.: func(who string) (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
103 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "other", who)
104 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
105 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/special",
106 }, nil
107 },
108 },
109 "non-current (missing)": {
110 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Path.: "~other/path/to/hooks",
111 WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#WantErr.: "could not find user other: missing",
112 lookupUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#lookupUser.: func(who string) (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
113 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, "other", who)
114 return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("missing")
115 },
116 },
117 } {
118 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(desc, c.Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandPathTestCase#Assert().)
119 }
120 }
121
122 type ExpandConfigPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase# struct {
123 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Path. string
124 DefaultPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#DefaultPath. string
125
126 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want. string
127 WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#WantErr. string
128
129 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#currentUser. func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error)
130 lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#lookupConfigHome. func() string
131 }
132
133 func (c *ExpandConfigPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#) Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Assert().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
134 if c.currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#currentUser. != nil {
135 oldCurrentUser := currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser.
136 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser. = c.currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#currentUser.
137 defer func() { currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/currentUser. = oldCurrentUser }()
138 }
139
140 if c.lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#lookupConfigHome. != nil {
141 oldLookupConfigHome := lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupConfigHome.
142 lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupConfigHome. = c.lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#lookupConfigHome.
143 defer func() { lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/lookupConfigHome. = oldLookupConfigHome }()
144 }
145
146 got, err := ExpandConfigPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPath().(c.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Path., c.DefaultPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#DefaultPath.)
147 if err != nil || len(c.WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#WantErr.) > 0 {
148 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualError().(t, err, c.WantErrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#WantErr.)
149 }
150 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/ToSlash().(c.Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want.), filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.ToSlashscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/ToSlash().(got))
151 }
152
153 func TestExpandConfigPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestExpandConfigPath().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
154 osscip-go gomod github.com/golang/go/src go1.25.0 os/.Unsetenvscip-go gomod github.com/golang/go/src go1.25.0 os/Unsetenv().("XDG_CONFIG_HOME")
155 for desc, c := range map[string]*ExpandConfigPathTestCasescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#{
156 "unexpanded full path": {
157 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Path.: "/path/to/attributes",
158 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want.: "/path/to/attributes",
159 },
160 "expanded full path": {
161 Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Path.: "~/path/to/attributes",
162 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want.: "/home/pat/path/to/attributes",
163 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#currentUser.: func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
164 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
165 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/pat",
166 }, nil
167 },
168 },
169 "expanded default path": {
170 DefaultPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#DefaultPath.: "git/attributes",
171 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want.: "/home/pat/.config/git/attributes",
172 currentUserscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#currentUser.: func() (*userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#, error) {
173 return &userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/.Userscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#{
174 HomeDirscip-go gomod github.com/golang/go/src go1.25.0 `os/user`/User#HomeDir.: "/home/pat",
175 }, nil
176 },
177 },
178 "XDG_CONFIG_HOME set": {
179 DefaultPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#DefaultPath.: "git/attributes",
180 Wantscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Want.: "/home/pat/configpath/git/attributes",
181 lookupConfigHomescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#lookupConfigHome.: func() string {
182 return "/home/pat/configpath"
183 },
184 },
185 } {
186 t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(desc, c.Assertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPathTestCase#Assert().)
187 }
188 }
189
190 func TestFastWalkBasicscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestFastWalkBasic().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
191 wd, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Getwdscip-go gomod github.com/golang/go/src go1.25.0 os/Getwd().()
192 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoError().(t, err)
193
194 rootDir := t.TempDirscip-go gomod github.com/golang/go/src go1.25.0 testing/common#TempDir().()
195 osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chdirscip-go gomod github.com/golang/go/src go1.25.0 os/Chdir().(rootDir)
196 defer osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chdirscip-go gomod github.com/golang/go/src go1.25.0 os/Chdir().(wd)
197
198 expectedEntries := createFastWalkInputDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/createFastWalkInputData().(10, 160)
199
200 walker := fastWalkDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkDir().(expectedEntries[0])
201 gotEntries, gotErrors := collectFastWalkResultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/collectFastWalkResults().(walker.chscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalker#ch.)
202
203 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Emptyscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Empty().(t, gotErrors)
204
205 sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Stringsscip-go gomod github.com/golang/go/src go1.25.0 sort/Strings().(expectedEntries)
206 sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Stringsscip-go gomod github.com/golang/go/src go1.25.0 sort/Strings().(gotEntries)
207 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, expectedEntries, gotEntries)
208 }
209
210 // Make test data - ensure you've Chdir'ed into a temp dir first
211 // Returns list of files/dirs that are created
212 // First entry is the parent dir of all others
213 func createFastWalkInputDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/createFastWalkInputData().(smallFolder, largeFolder int) []string {
214 dirs := []string{
215 "testroot",
216 "testroot/folder1",
217 "testroot/folder2",
218 "testroot/folder2/subfolder1",
219 "testroot/folder2/subfolder2",
220 "testroot/folder2/subfolder3",
221 "testroot/folder2/subfolder4",
222 "testroot/folder2/subfolder4/subsub",
223 }
224 expectedEntries := make([]string, 0, 250)
225
226 for i, dir := range dirs {
227 osscip-go gomod github.com/golang/go/src go1.25.0 os/.MkdirAllscip-go gomod github.com/golang/go/src go1.25.0 os/MkdirAll().(dir, 0755)
228 numFiles := smallFolder
229 expectedEntries = append(expectedEntries, dir)
230 if i >= 3 && i <= 5 {
231 // Bulk test to ensure works with > 1 batch
232 numFiles = largeFolder
233 }
234 for f := 0; f < numFiles; f++ {
235 filename := joinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/join().(dir, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("file%d.txt", f))
236 osscip-go gomod github.com/golang/go/src go1.25.0 os/.WriteFilescip-go gomod github.com/golang/go/src go1.25.0 os/WriteFile().(filename, []byte("TEST"), 0644)
237 expectedEntries = append(expectedEntries, filename)
238 }
239 }
240
241 return expectedEntries
242 }
243
244 func collectFastWalkResultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/collectFastWalkResults().(fchan <-chan fastWalkInfoscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#) ([]string, []error) {
245 gotEntries := make([]string, 0, 1000)
246 gotErrors := make([]error, 0, 5)
247 for o := range fchan {
248 if o.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#Err. != nil {
249 gotErrors = append(gotErrors, o.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#Err.)
250 } else {
251 if len(o.ParentDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#ParentDir.) == 0 {
252 gotEntries = append(gotEntries, o.Infoscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#Info..Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Name().())
253 } else {
254 gotEntries = append(gotEntries, joinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/join().(o.ParentDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#ParentDir., o.Infoscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/fastWalkInfo#Info..Namescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Name().()))
255 }
256 }
257 }
258
259 return gotEntries, gotErrors
260 }
261
262 func getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename string) osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileModescip-go gomod github.com/golang/go/src go1.25.0 os/FileMode# {
263 s, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Statscip-go gomod github.com/golang/go/src go1.25.0 os/Stat().(filename)
264 if err != nil {
265 return 0000
266 }
267 return s.Modescip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#Mode().()
268 }
269
270 // uniq creates an element-wise copy of "xs" containing only unique elements in
271 // the same order.
272 func uniqscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/uniq().(xs []string) []string {
273 seen := make(map[string]struct{})
274 uniq := make([]string, 0, len(xs))
275
276 for _, x := range xs {
277 if _, ok := seen[x]; !ok {
278 seen[x] = struct{}{}
279 uniq = append(uniq, x)
280 }
281 }
282
283 return uniq
284 }
285
286 func TestSetWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestSetWriteFlag().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
287 f, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.CreateTempscip-go gomod github.com/golang/go/src go1.25.0 os/CreateTemp().("", "lfstestwriteflag")
288 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, err)
289 filename := f.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().()
290 defer osscip-go gomod github.com/golang/go/src go1.25.0 os/.Removescip-go gomod github.com/golang/go/src go1.25.0 os/Remove().(filename)
291 f.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
292 // Set up with read/write bit for all but no execute
293 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chmodscip-go gomod github.com/golang/go/src go1.25.0 os/Chmod().(filename, 0666))
294
295 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, false))
296 // should turn off all write
297 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0444, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
298 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, true))
299 // should only add back user write (on Mac/Linux)
300 if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. == "windows" {
301 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0666, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
302 } else {
303 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0644, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
304 }
305
306 // Can't run selective UGO tests on Windows as doesn't support separate roles
307 // Also Golang only supports read/write but not execute on Windows
308 if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. != "windows" {
309 // Set up with read/write/execute bit for all but no execute
310 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chmodscip-go gomod github.com/golang/go/src go1.25.0 os/Chmod().(filename, 0777))
311 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, false))
312 // should turn off all write but not execute
313 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0555, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
314 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, true))
315 // should only add back user write (on Mac/Linux)
316 if runtimescip-go gomod github.com/golang/go/src go1.25.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.25.0 runtime/GOOS. == "windows" {
317 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0777, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
318 } else {
319 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0755, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
320 }
321
322 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.Chmodscip-go gomod github.com/golang/go/src go1.25.0 os/Chmod().(filename, 0440))
323 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, false))
324 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0440, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
325 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, SetFileWriteFlagscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/SetFileWriteFlag().(filename, true))
326 // should only add back user write
327 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, 0640, getFileModescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/getFileMode().(filename))
328 }
329 }
330
331 func TestExecutablePermissionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TestExecutablePermissions().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) {
332 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileModescip-go gomod github.com/golang/go/src go1.25.0 os/FileMode#(0755), ExecutablePermissionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExecutablePermissions().(0644))
333 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileModescip-go gomod github.com/golang/go/src go1.25.0 os/FileMode#(0750), ExecutablePermissionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExecutablePermissions().(0640))
334 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.EqualValuesscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/EqualValues().(t, osscip-go gomod github.com/golang/go/src go1.25.0 os/.FileModescip-go gomod github.com/golang/go/src go1.25.0 os/FileMode#(0700), ExecutablePermissionsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExecutablePermissions().(0600))
335 }