MCPcopy Create free account
hub / github.com/wailsapp/wails / EscapeName

Function EscapeName

v2/pkg/git/git.go:43–59  ·  view source on GitHub ↗
(str string)

Source from the content-addressed store, hash-verified

41}
42
43func EscapeName(str string) (string, error) {
44 b, err := json.Marshal(str)
45 if err != nil {
46 return "", err
47 }
48 // Remove the surrounding quotes
49 escaped := string(b[1 : len(b)-1])
50
51 // Check if username is JSON compliant
52 var js json.RawMessage
53 jsonVal := fmt.Sprintf(`{"name": "%s"}`, escaped)
54 err = json.Unmarshal([]byte(jsonVal), &js)
55 if err != nil {
56 return "", fmt.Errorf("failed to retrieve git user name: %w", err)
57 }
58 return escaped, nil
59}
60
61func InitRepo(projectDir string) error {
62 _, _, err := shell.RunCommand(projectDir, gitcommand(), "init")

Callers 2

NameFunction · 0.85
TestEscapeName1Function · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by 1

TestEscapeName1Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…