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

Function encodeRepoPath

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

Source from the content-addressed store, hash-verified

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

Callers 10

SessionFilePathFunction · 0.85
TestEncodeRepoPathFunction · 0.85
sessionJSONLPathFunction · 0.85
openMethod · 0.85
rawPathFunction · 0.85
NewRawFileWriterFunction · 0.85
SessionsDirFunction · 0.85

Calls

no outgoing calls

Tested by 6

TestEncodeRepoPathFunction · 0.68
sessionJSONLPathFunction · 0.68
rawPathFunction · 0.68