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

Function checkCleanWorkingDirectory

pkg/cli/git.go:526–541  ·  view source on GitHub ↗

checkCleanWorkingDirectory checks if there are uncommitted changes

(verbose bool)

Source from the content-addressed store, hash-verified

524
525// checkCleanWorkingDirectory checks if there are uncommitted changes
526func checkCleanWorkingDirectory(verbose bool) error {
527 console.LogVerbose(verbose, "Checking for uncommitted changes...")
528
529 cmd := exec.Command("git", "status", "--porcelain")
530 output, err := cmd.Output()
531 if err != nil {
532 return fmt.Errorf("failed to check git status: %w", err)
533 }
534
535 if len(strings.TrimSpace(string(output))) > 0 {
536 return errors.New("working directory has uncommitted changes, please commit or stash them first")
537 }
538
539 console.LogVerbose(verbose, "Working directory is clean")
540 return nil
541}
542
543// WorkflowFileStatus represents the status of a workflow file in git
544type WorkflowFileStatus struct {

Callers 3

AddResolvedWorkflowsFunction · 0.85

Calls 2

LogVerboseFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected