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

Function encodeRepoPath

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

Source from the content-addressed store, hash-verified

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