| 1 | package gitattrscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/ |
| 2 | |
| 3 | import ( |
| 4 | "errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/" |
| 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 | "pathscip-go gomod github.com/golang/go/src go1.25.0 path/" |
| 8 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 9 | "sortscip-go gomod github.com/golang/go/src go1.25.0 sort/" |
| 10 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 11 | |
| 12 | "github.com/git-lfs/git-lfs/v3/filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/" |
| 13 | "github.com/git-lfs/git-lfs/v3/gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/" |
| 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 | "github.com/rubyist/tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/" |
| 17 | ) |
| 18 | |
| 19 | const ( |
| 20 | LockableAttribscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/LockableAttrib. = "lockable" |
| 21 | FilterAttribscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/FilterAttrib. = "filter" |
| 22 | ) |
| 23 | |
| 24 | // AttributePath is a path entry in a gitattributes file which has the LFS filter |
| 25 | type AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath# struct { |
| 26 | // Path entry in the attribute file |
| 27 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Path. string |
| 28 | // The attribute file which was the source of this entry |
| 29 | Sourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Source. *AttributeSourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource# |
| 30 | // Path also has the 'lockable' attribute |
| 31 | Lockablescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Lockable. bool |
| 32 | // Path is handled by Git LFS (i.e., filter=lfs) |
| 33 | Trackedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Tracked. bool |
| 34 | } |
| 35 | |
| 36 | type AttributeSourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource# struct { |
| 37 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#Path. string |
| 38 | LineEndingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#LineEnding. string |
| 39 | } |
| 40 | |
| 41 | type attrFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile# struct { |
| 42 | pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path. string |
| 43 | readMacrosscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#readMacros. bool |
| 44 | } |
| 45 | |
| 46 | func (s *AttributeSourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#) Stringscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#String().() string { |
| 47 | return s.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#Path. |
| 48 | } |
| 49 | |
| 50 | // GetUserAttributePaths behaves as GetAttributePaths, and loads information |
| 51 | // only from the user's global attributes file. |
| 52 | func GetUserAttributePathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetUserAttributePaths().(mp *MacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#, gitEnv Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#) ([]AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#, error) { |
| 53 | path, err := GetUserAttributeFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetUserAttributeFilePath().(gitEnv) |
| 54 | if err != nil || len(path) == 0 { |
| 55 | return nil, err |
| 56 | } |
| 57 | |
| 58 | reader, 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().(path) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | defer reader.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 63 | // The working directory for the user gitattributes file is blank. |
| 64 | return AttrPathsFromReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttrPathsFromReader().(mp, path, "", reader, true), nil |
| 65 | } |
| 66 | |
| 67 | func GetUserAttributeFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetUserAttributeFilePath().(gitEnv Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#) (string, error) { |
| 68 | path, _ := gitEnv.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#Get.("core.attributesfile") |
| 69 | path, err := toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.ExpandConfigPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/ExpandConfigPath().(path, "git/attributes") |
| 70 | if err != nil { |
| 71 | return "", err |
| 72 | } |
| 73 | if _, 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().(path); osscip-go gomod github.com/golang/go/src go1.25.0 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/IsNotExist().(err) { |
| 74 | return "", nil |
| 75 | } |
| 76 | return path, nil |
| 77 | } |
| 78 | |
| 79 | func GetRepoAttributeFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetRepoAttributeFilePath().(gitDir string) (string, error) { |
| 80 | path := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(gitDir, "info", "attributes") |
| 81 | |
| 82 | if _, 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().(path); osscip-go gomod github.com/golang/go/src go1.25.0 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/IsNotExist().(err) { |
| 83 | return "", nil |
| 84 | } |
| 85 | return path, nil |
| 86 | } |
| 87 | |
| 88 | // GetSystemAttributePaths behaves as GetAttributePaths, and loads information |
| 89 | // only from the system gitattributes file, respecting the $PREFIX environment |
| 90 | // variable. |
| 91 | func GetSystemAttributePathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetSystemAttributePaths().(mp *MacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#, env Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#) ([]AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#, error) { |
| 92 | path, err := GetSystemAttributeFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetSystemAttributeFilePath().(env) |
| 93 | if err != nil || len(path) == 0 { |
| 94 | return nil, err |
| 95 | } |
| 96 | |
| 97 | reader, 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().(path) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } |
| 101 | defer reader.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 102 | // The working directory for the system gitattributes file is blank. |
| 103 | return AttrPathsFromReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttrPathsFromReader().(mp, path, "", reader, true), nil |
| 104 | } |
| 105 | |
| 106 | func GetSystemAttributeFilePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetSystemAttributeFilePath().(osEnv Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#) (string, error) { |
| 107 | var path string |
| 108 | if gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.IsGitVersionAtLeastscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/IsGitVersionAtLeast().("2.42.0") { |
| 109 | cmd, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.Varscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/Var().("GIT_ATTR_SYSTEM") |
| 110 | if err != nil { |
| 111 | return "", errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 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().("failed to find `git var GIT_ATTR_SYSTEM`: %v", err)) |
| 112 | } |
| 113 | out, err := cmd.Outputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/subprocess`/Cmd#Output().() |
| 114 | if err != nil { |
| 115 | return "", errorsscip-go gomod github.com/golang/go/src go1.25.0 errors/.Newscip-go gomod github.com/golang/go/src go1.25.0 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().("failed to call `git var GIT_ATTR_SYSTEM`: %v", err)) |
| 116 | } |
| 117 | paths := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Splitscip-go gomod github.com/golang/go/src go1.25.0 strings/Split().(string(out), "\n") |
| 118 | if len(paths) == 0 { |
| 119 | return "", nil |
| 120 | } |
| 121 | path = paths[0] |
| 122 | } else { |
| 123 | prefix, _ := osEnv.Getscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Environment#Get.("PREFIX") |
| 124 | if len(prefix) == 0 { |
| 125 | prefix = string(filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Separatorscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Separator.) |
| 126 | } |
| 127 | |
| 128 | path = filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(prefix, "etc", "gitattributes") |
| 129 | } |
| 130 | |
| 131 | if _, 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().(path); osscip-go gomod github.com/golang/go/src go1.25.0 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/IsNotExist().(err) { |
| 132 | return "", nil |
| 133 | } |
| 134 | |
| 135 | return path, nil |
| 136 | } |
| 137 | |
| 138 | // GetAttributePaths returns a list of entries in .gitattributes which are |
| 139 | // configured with the filter=lfs attribute |
| 140 | // workingDir is the root of the working copy |
| 141 | // gitDir is the root of the git repo |
| 142 | func GetAttributePathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetAttributePaths().(mp *MacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#, workingDir, gitDir string) []AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath# { |
| 143 | paths := make([]AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#, 0) |
| 144 | |
| 145 | for _, file := range findAttributeFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/findAttributeFiles().(workingDir, gitDir) { |
| 146 | paths = append(paths, attrPathsFromFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrPathsFromFile().(mp, file.pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path., workingDir, file.readMacrosscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#readMacros.)...) |
| 147 | } |
| 148 | |
| 149 | return paths |
| 150 | } |
| 151 | |
| 152 | func attrPathsFromFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrPathsFromFile().(mp *MacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#, path, workingDir string, readMacros bool) []AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath# { |
| 153 | attributes, 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().(path) |
| 154 | if err != nil { |
| 155 | return nil |
| 156 | } |
| 157 | defer attributes.Closescip-go gomod github.com/golang/go/src go1.25.0 os/File#Close().() |
| 158 | return AttrPathsFromReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttrPathsFromReader().(mp, path, workingDir, attributes, readMacros) |
| 159 | } |
| 160 | |
| 161 | func AttrPathsFromReaderscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttrPathsFromReader().(mp *MacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#, fpath, workingDir string, rdr ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Readerscip-go gomod github.com/golang/go/src go1.25.0 io/Reader#, readMacros bool) []AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath# { |
| 162 | var paths []AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath# |
| 163 | |
| 164 | relfile, _ := 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().(workingDir, fpath) |
| 165 | // Go 1.20 now always returns ".\foo" instead of "foo" in filepath.Rel, |
| 166 | // but only on Windows. Strip the extra dot here so our paths are |
| 167 | // always fully relative with no "." or ".." components. |
| 168 | reldir := 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().(toolsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/.TrimCurrentPrefixscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/TrimCurrentPrefix().(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().(relfile))) |
| 169 | if reldir == "." { |
| 170 | reldir = "" |
| 171 | } |
| 172 | source := &AttributeSourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#{Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#Path.: relfile} |
| 173 | |
| 174 | lines, eol, err := ParseLinesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/ParseLines().(rdr) |
| 175 | if err != nil { |
| 176 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("Error parsing attributes from %s: %v", fpath, err) |
| 177 | return nil |
| 178 | } |
| 179 | |
| 180 | patternLines := mp.ProcessLinesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/MacroProcessor#ProcessLines().(lines, readMacros) |
| 181 | |
| 182 | for _, line := range patternLines { |
| 183 | lockable := false |
| 184 | tracked := false |
| 185 | hasFilter := false |
| 186 | |
| 187 | for _, attr := range line.Attrsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Line#Attrs.() { |
| 188 | if attr.Kscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#K. == FilterAttribscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/FilterAttrib. { |
| 189 | hasFilter = true |
| 190 | tracked = attr.Vscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#V. == "lfs" |
| 191 | } else if attr.Kscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#K. == LockableAttribscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/LockableAttrib. && attr.Vscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/Attr#V. == "true" { |
| 192 | lockable = true |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | if !hasFilter && !lockable { |
| 197 | continue |
| 198 | } |
| 199 | |
| 200 | pattern := line.Patternscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/PatternLine#Pattern.().Stringscip-go gomod github.com/git-lfs/wildmatch/v2 v2.0.1 `github.com/git-lfs/wildmatch/v2`/Wildmatch#String().() |
| 201 | if len(reldir) > 0 { |
| 202 | pattern = pathscip-go gomod github.com/golang/go/src go1.25.0 path/.Joinscip-go gomod github.com/golang/go/src go1.25.0 path/Join().(reldir, pattern) |
| 203 | } |
| 204 | |
| 205 | paths = append(paths, AttributePathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#{ |
| 206 | Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Path.: pattern, |
| 207 | Sourcescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Source.: source, |
| 208 | Lockablescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Lockable.: lockable, |
| 209 | Trackedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Tracked.: tracked, |
| 210 | }) |
| 211 | } |
| 212 | |
| 213 | source.LineEndingscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributeSource#LineEnding. = eol |
| 214 | |
| 215 | return paths |
| 216 | } |
| 217 | |
| 218 | // GetAttributeFilter returns a list of entries in .gitattributes which are |
| 219 | // configured with the filter=lfs attribute as a file path filter which |
| 220 | // file paths can be matched against |
| 221 | // workingDir is the root of the working copy |
| 222 | // gitDir is the root of the git repo |
| 223 | func GetAttributeFilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetAttributeFilter().(gitEnv filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Environment#, workingDir, gitDir string) *filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Filterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Filter# { |
| 224 | paths := GetAttributePathsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/GetAttributePaths().(NewMacroProcessorscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/NewMacroProcessor().(), workingDir, gitDir) |
| 225 | patterns := make([]filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.Patternscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/Pattern#, 0, len(paths)) |
| 226 | |
| 227 | for _, path := range paths { |
| 228 | // Convert all separators to `/` before creating a pattern to |
| 229 | // avoid characters being escaped in situations like `subtree\*.md` |
| 230 | patterns = append(patterns, filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.NewPatternscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/NewPattern().(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().(path.Pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/AttributePath#Path.), filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.GitAttributesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/GitAttributes., gitEnv)) |
| 231 | } |
| 232 | |
| 233 | return filepathfilterscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/.NewFromPatternsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/filepathfilter`/NewFromPatterns().(patterns, nil) |
| 234 | } |
| 235 | |
| 236 | // findAttributeFiles finds all attributes files in the repository, starting with the repository-wide attributes |
| 237 | // file, and then any .gitattributes files in the working tree |
| 238 | func findAttributeFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/findAttributeFiles().(workingDir, gitDir string) []attrFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile# { |
| 239 | var paths []attrFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile# |
| 240 | |
| 241 | repoAttributes := filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(gitDir, "info", "attributes") |
| 242 | if info, 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().(repoAttributes); err == nil && !info.IsDirscip-go gomod github.com/golang/go/src go1.25.0 `io/fs`/FileInfo#IsDir().() { |
| 243 | paths = append(paths, attrFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#{pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path.: repoAttributes, readMacrosscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#readMacros.: true}) |
| 244 | } |
| 245 | |
| 246 | lsFiles, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.NewLsFilesscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewLsFiles().(workingDir, true, true) |
| 247 | if err != nil { |
| 248 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("Error finding .gitattributes: %v", err) |
| 249 | return paths |
| 250 | } |
| 251 | |
| 252 | if gitattributesFiles, present := lsFiles.FilesByNamescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/LsFiles#FilesByName.[".gitattributes"]; present { |
| 253 | for _, f := range gitattributesFiles { |
| 254 | tracerxscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/.Printfscip-go gomod github.com/rubyist/tracerx 787959303086 `github.com/rubyist/tracerx`/Printf().("findAttributeFiles: located %s", f.FullPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/lsFileInfo#FullPath.) |
| 255 | paths = append(paths, attrFilescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#{ |
| 256 | pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path.: filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().(workingDir, f.FullPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/lsFileInfo#FullPath.), |
| 257 | readMacrosscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#readMacros.: f.FullPathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/lsFileInfo#FullPath. == ".gitattributes", // Read macros from the top-level attributes |
| 258 | }) |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | // reverse the order of the files so more specific entries are found first |
| 263 | // when iterating from the front (respects precedence) |
| 264 | sortscip-go gomod github.com/golang/go/src go1.25.0 sort/.Slicescip-go gomod github.com/golang/go/src go1.25.0 sort/Slice().(paths[:], func(i, j int) bool { |
| 265 | return len(paths[i].pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path.) > len(paths[j].pathscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git/gitattr`/attrFile#path.) |
| 266 | }) |
| 267 | |
| 268 | return paths |
| 269 | } |