Debian Codegraph @

lfs/util.go

raw symbols SCIP
1 package lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/"
5 "ioscip-go gomod github.com/golang/go/src go1.25.0 io/"
6 "osscip-go gomod github.com/golang/go/src go1.25.0 os/"
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 "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/"
10
11 "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/"
12 "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/"
13 "github.com/git-lfs/git-lfs/v3/tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/"
14 "github.com/git-lfs/git-lfs/v3/toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/"
15 "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/"
16 )
17
18 type Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform# int
19
20 const (
21 PlatformWindowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformWindows. = Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform#(iota)
22 PlatformLinuxscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformLinux. = Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform#(iota)
23 PlatformOSXscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformOSX. = Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform#(iota)
24 PlatformOtherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformOther. = Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform#(iota) // most likely a *nix variant e.g. freebsd
25 PlatformUndeterminedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformUndetermined. = Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform#(iota)
26 )
27
28 var currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. = PlatformUndeterminedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformUndetermined.
29
30 func joinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/join().(parts ...string) string {
31 return stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Joinscip-go gomod github.com/golang/go/src go1.25.0 strings/Join().(parts, "/")
32 }
33
34 func (f *GitFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#) CopyCallbackFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#CopyCallbackFile().(event, filename string, index, totalFiles int) (toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CopyCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyCallback#, *osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#, error) {
35 logPath, _ := f.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg..Osscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#Os..Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#Get.("GIT_LFS_PROGRESS")
36 if len(logPath) == 0 || len(filename) == 0 || len(event) == 0 {
37 return nil, nil, nil
38 }
39
40 if !filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(logPath) {
41 return nil, nil, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("GIT_LFS_PROGRESS must be an absolute path"))
42 }
43
44 cbDir := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Dir().(logPath)
45 if err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.MkdirAllscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/MkdirAll().(cbDir, f.cfgscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#cfg.); err != nil {
46 return nil, nil, wrapProgressErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/wrapProgressError().(err, event, logPath)
47 }
48
49 file, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.OpenFilescip-go gomod github.com/golang/go/src go1.25.0 os/OpenFile().(logPath, osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_WRONLYscip-go gomod github.com/golang/go/src go1.25.0 os/O_WRONLY.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_CREATEscip-go gomod github.com/golang/go/src go1.25.0 os/O_CREATE.|osscip-go gomod github.com/golang/go/src go1.25.0 os/.O_APPENDscip-go gomod github.com/golang/go/src go1.25.0 os/O_APPEND., 0666)
50 if err != nil {
51 return nil, file, wrapProgressErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/wrapProgressError().(err, event, logPath)
52 }
53
54 var (
55 prevTotal int64
56 prevWritten int64
57 hasReachedTotal bool
58 )
59 deadline := f.clkscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#clk..Nowscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/Clock#Now().().Addscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Add().(tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.DefaultLoggingThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/DefaultLoggingThrottle.)
60 cb := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.CopyCallbackscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/CopyCallback#(func(total int64, written int64, current int) error {
61 now := f.clkscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GitFilter#clk..Nowscip-go gomod github.com/jmhodges/clock v1.2.0 `github.com/jmhodges/clock`/Clock#Now().()
62
63 if total == prevTotal {
64 if written == prevWritten {
65 return nil
66 }
67 } else {
68 hasReachedTotal = false
69 }
70
71 logOptional := total < 0 || written < total || hasReachedTotal
72 if logOptional && now.Beforescip-go gomod github.com/golang/go/src go1.25.0 time/Time#Before().(deadline) {
73 return nil
74 }
75
76 writtenFraction := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.FormatFractionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/FormatFraction().(written, total)
77
78 _, err := fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Fprintf().(file, "%s %d/%d %s %s\n", event, index, totalFiles, writtenFraction, filename)
79 file.Syncscip-go gomod github.com/golang/go/src go1.25.0 os/File#Sync().()
80
81 prevTotal = total
82 prevWritten = written
83 if !logOptional {
84 hasReachedTotal = true
85 }
86
87 deadline = now.Addscip-go gomod github.com/golang/go/src go1.25.0 time/Time#Add().(tasklogscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/.DefaultLoggingThrottlescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tasklog`/DefaultLoggingThrottle.)
88 return wrapProgressErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/wrapProgressError().(err, event, logPath)
89 })
90
91 return cb, file, nil
92 }
93
94 func wrapProgressErrorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/wrapProgressError().(err error, event, filename string) error {
95 if err != nil {
96 return errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("error writing Git LFS %s progress to %s: %s", event, filename, err.Error()))
97 }
98
99 return nil
100 }
101
102 var localDirSetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/localDirSet. = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.NewStringSetFromSlicescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/NewStringSetFromSlice().([]string{".", "./", ".\\"})
103
104 func GetPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GetPlatform().() Platformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Platform# {
105 if currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. == PlatformUndeterminedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformUndetermined. {
106 switch 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. {
107 case "windows":
108 currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. = PlatformWindowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformWindows.
109 case "linux":
110 currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. = PlatformLinuxscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformLinux.
111 case "darwin":
112 currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. = PlatformOSXscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformOSX.
113 default:
114 currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform. = PlatformOtherscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformOther.
115 }
116 }
117 return currentPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentPlatform.
118 }
119
120 type PathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PathConverter# interface {
121 Convertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PathConverter#Convert.(string) string
122 }
123
124 // Convert filenames expressed relative to the current directory to be
125 // relative to the repo root. Useful when calling git with arguments that requires them
126 // to be rooted but the user is in a subdir of their repo & expects to use relative args
127 func NewCurrentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewCurrentToRepoPathConverter().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#) (PathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PathConverter#, error) {
128 r, c, p, err := pathConverterArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pathConverterArgs().(cfg)
129 if err != nil {
130 return nil, err
131 }
132
133 return &currentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#{
134 repoDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#repoDir.: r,
135 currDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#currDir.: c,
136 passthroughscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#passthrough.: p,
137 }, nil
138 }
139
140 type currentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter# struct {
141 repoDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#repoDir. string
142 currDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#currDir. string
143 passthroughscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#passthrough. bool
144 }
145
146 func (p *currentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#) Convertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#Convert().(filename string) string {
147 if p.passthroughscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#passthrough. {
148 return filename
149 }
150
151 var abs string
152 if filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.IsAbsscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/IsAbs().(filename) {
153 abs = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.ResolveSymlinksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ResolveSymlinks().(filename)
154 } else {
155 abs = joinscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/join().(p.currDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#currDir., filename)
156 }
157 reltoroot, err := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Relscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Rel().(p.repoDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#repoDir., abs)
158 if err != nil {
159 // Can't do this, use absolute as best fallback
160 return abs
161 }
162 return 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().(reltoroot)
163 }
164
165 // Convert filenames expressed relative to the current directory to be relative
166 // to the repo root and convert them into wildmatch patterns.
167 func NewCurrentToRepoPatternConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewCurrentToRepoPatternConverter().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#) (PathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PathConverter#, error) {
168 r, c, p, err := pathConverterArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pathConverterArgs().(cfg)
169 if err != nil {
170 return nil, err
171 }
172
173 return &currentToRepoPatternConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#{
174 cscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#c.: &currentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#{
175 repoDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#repoDir.: r,
176 currDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#currDir.: c,
177 passthroughscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#passthrough.: p,
178 },
179 }, nil
180 }
181
182 type currentToRepoPatternConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter# struct {
183 cscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#c. *currentToRepoPathConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#
184 }
185
186 func (p *currentToRepoPatternConverterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#) Convertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#Convert().(filename string) string {
187 pattern := p.cscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPatternConverter#c..Convertscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/currentToRepoPathConverter#Convert().(filename)
188 if st, 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); err == nil && st.IsDirscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#IsDir().() {
189 pattern += "/"
190 }
191 if stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.HasPrefixscip-go gomod github.com/golang/go/src go1.25.0 strings/HasPrefix().(pattern, "./") {
192 pattern = pattern[2:]
193 if len(pattern) == 0 {
194 pattern = "**"
195 }
196 }
197 return pattern
198 }
199
200 func pathConverterArgsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/pathConverterArgs().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#) (string, string, bool, error) {
201 currDir, 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().()
202 if err != nil {
203 return "", "", false, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("unable to get working dir: %v", err))
204 }
205 currDir = toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.ResolveSymlinksscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ResolveSymlinks().(currDir)
206 return cfg.LocalWorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LocalWorkingDir().(), currDir, cfg.LocalWorkingDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#LocalWorkingDir().() == currDir, nil
207 }
208
209 // Are we running on Windows? Need to handle some extra path shenanigans
210 func IsWindowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/IsWindows().() bool {
211 return GetPlatformscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/GetPlatform().() == PlatformWindowsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PlatformWindows.
212 }
213
214 func CopyFileContentsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/CopyFileContents().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, src string, dst string) error {
215 tmp, err := TempFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TempFile().(cfg, filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Basescip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Base().(dst))
216 if err != nil {
217 return err
218 }
219 defer func() {
220 tmp.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
221 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().(tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().())
222 }()
223 in, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Openscip-go gomod github.com/golang/go/src go1.25.0 os/Open().(src)
224 if err != nil {
225 return err
226 }
227 defer in.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
228 _, err = ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Copyscip-go gomod github.com/golang/go/src go1.25.0 io/Copy().(tmp, in)
229 if err != nil {
230 return err
231 }
232 err = tmp.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().()
233 if err != nil {
234 return err
235 }
236 return osscip-go gomod github.com/golang/go/src go1.25.0 os/.Renamescip-go gomod github.com/golang/go/src go1.25.0 os/Rename().(tmp.Namescip-go gomod github.com/golang/go/src go1.25.0 os/File#Name().(), dst)
237 }
238
239 func LinkOrCopyscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/LinkOrCopy().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, src string, dst string) error {
240 if src == dst {
241 return nil
242 }
243 err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Linkscip-go gomod github.com/golang/go/src go1.25.0 os/Link().(src, dst)
244 if err == nil {
245 return err
246 }
247 return CopyFileContentsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/CopyFileContents().(cfg, src, dst)
248 }
249
250 // TempFile creates a temporary file in the temporary directory specified by the
251 // configuration that has the proper permissions for the repository. On
252 // success, it returns an open, non-nil *os.File, and the caller is responsible
253 // for closing and/or removing it. On failure, the temporary file is
254 // automatically cleaned up and an error returned.
255 //
256 // This function is designed to handle only temporary files that will be renamed
257 // into place later somewhere within the Git repository.
258 func TempFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TempFile().(cfg *configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Configurationscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#, pattern string) (*osscip-go gomod github.com/golang/go/src go1.25.0 os/.Filescip-go gomod github.com/golang/go/src go1.25.0 os/File#, error) {
259 return toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.TempFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TempFile().(cfg.TempDirscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Configuration#TempDir().(), pattern, cfg)
260 }