MCPcopy
hub / github.com/github/git-sizer / Path

Method Path

sizes/path_resolver.go:153–180  ·  view source on GitHub ↗

Return a human-readable path for this object if we can do better than its OID; otherwise, return "".

()

Source from the content-addressed store, hash-verified

151// Return a human-readable path for this object if we can do better
152// than its OID; otherwise, return "".
153func (p *Path) Path() string {
154 switch p.objectType {
155 case "blob", "tree":
156 if p.parent != nil {
157 if p.relativePath == "" {
158 // This is a top-level tree or blob.
159 return fmt.Sprintf("%s^{%s}", p.parent.BestPath(), p.objectType)
160 } else {
161 // The parent is also a tree.
162 return p.parent.TreePrefix() + p.relativePath
163 }
164 } else {
165 return ""
166 }
167 case "commit", "tag":
168 switch {
169 case p.parent != nil:
170 // The parent is a tag.
171 return fmt.Sprintf("%s^{%s}", p.parent.BestPath(), p.objectType)
172 case p.relativePath != "":
173 return p.relativePath
174 default:
175 return ""
176 }
177 default:
178 return ""
179 }
180}
181
182// Return some human-readable path for this object, even if it's just
183// the OID.

Callers 3

BestPathMethod · 0.95
StringMethod · 0.95
MarshalJSONMethod · 0.45

Calls 2

BestPathMethod · 0.80
TreePrefixMethod · 0.80

Tested by

no test coverage detected