(str string)
| 41 | } |
| 42 | |
| 43 | func 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 | |
| 61 | func InitRepo(projectDir string) error { |
| 62 | _, _, err := shell.RunCommand(projectDir, gitcommand(), "init") |
searching dependent graphs…