MCPcopy Create free account
hub / github.com/github/gh-aw / resetActionPinsFile

Function resetActionPinsFile

pkg/cli/compile_compiler_setup.go:46–80  ·  view source on GitHub ↗

resetActionPinsFile resets the action_pins.json file to an empty state

()

Source from the content-addressed store, hash-verified

44
45// resetActionPinsFile resets the action_pins.json file to an empty state
46func resetActionPinsFile() error {
47 compileCompilerSetupLog.Print("Resetting action_pins.json to empty state")
48
49 // Get the path to action_pins.json relative to the repository root
50 // This assumes the command is run from the repository root
51 actionPinsPath := filepath.Join("pkg", "workflow", "data", "action_pins.json")
52
53 // Check if file exists
54 if _, err := os.Stat(actionPinsPath); os.IsNotExist(err) {
55 compileCompilerSetupLog.Printf("action_pins.json does not exist at %s, skipping reset", actionPinsPath)
56 return nil
57 }
58
59 // Create empty structure matching the schema
60 emptyData := map[string]any{
61 "entries": map[string]any{},
62 }
63
64 // Marshal with pretty printing
65 data, err := json.MarshalIndent(emptyData, "", " ")
66 if err != nil {
67 return fmt.Errorf("failed to marshal empty action pins: %w", err)
68 }
69
70 // Add trailing newline for prettier compliance
71 data = append(data, '\n')
72
73 // Write the file
74 if err := os.WriteFile(actionPinsPath, data, constants.FilePermPublic); err != nil {
75 return fmt.Errorf("failed to write action_pins.json: %w", err)
76 }
77
78 compileCompilerSetupLog.Printf("Successfully reset %s to empty state", actionPinsPath)
79 return nil
80}
81
82// createAndConfigureCompiler creates a new compiler instance and configures it
83// based on the provided configuration

Calls 3

PrintMethod · 0.80
PrintfMethod · 0.45
ErrorfMethod · 0.45