MCPcopy Create free account
hub / github.com/alibaba/open-code-review / encodeRepoPath

Function encodeRepoPath

internal/session/persist.go:76–101  ·  view source on GitHub ↗
(p string)

Source from the content-addressed store, hash-verified

74}
75
76func encodeRepoPath(p string) string {
77 // Handle empty or invalid input
78 if p == "" {
79 return "empty"
80 }
81
82 vol := filepath.VolumeName(p)
83 p = p[len(vol):]
84
85 // Trim leading path separators
86 p = strings.TrimLeft(p, "/\\")
87
88 // Replace separators with -
89 p = strings.ReplaceAll(p, "/", "-")
90 p = strings.ReplaceAll(p, "\\", "-")
91
92 // Replace colons (from Windows drive letters)
93 vol = strings.ReplaceAll(vol, ":", "_")
94
95 // Handle edge case where path was only separators or volume name
96 result := vol + p
97 if result == "" {
98 return "empty"
99 }
100 return result
101}
102
103func (jw *jsonlWriter) open() error {
104 home, err := os.UserHomeDir()

Callers 7

SessionFilePathFunction · 0.85
TestEncodeRepoPathFunction · 0.85
sessionJSONLPathFunction · 0.85
openMethod · 0.85
SessionsDirFunction · 0.85

Calls

no outgoing calls

Tested by 4

TestEncodeRepoPathFunction · 0.68
sessionJSONLPathFunction · 0.68