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

Function ensureUpdateTargetRepoGitignore

pkg/cli/update_command.go:346–369  ·  view source on GitHub ↗
(gitRoot string)

Source from the content-addressed store, hash-verified

344}
345
346func ensureUpdateTargetRepoGitignore(gitRoot string) (string, error) {
347 updatesDir := filepath.Join(gitRoot, updateTargetRepoCheckoutDir)
348 if err := os.MkdirAll(updatesDir, constants.DirPermPublic); err != nil {
349 return "", fmt.Errorf("failed to create %s: %w", updateTargetRepoCheckoutDir, err)
350 }
351
352 gitignorePath := filepath.Join(updatesDir, ".gitignore")
353 if _, err := os.Stat(gitignorePath); err == nil {
354 return updatesDir, nil
355 } else if !errors.Is(err, os.ErrNotExist) {
356 return "", fmt.Errorf("failed to stat %s: %w", gitignorePath, err)
357 }
358
359 const gitignoreContent = `# Ignore checked-out repositories used by 'gh aw update --repo'
360*
361
362# Keep this file in version control
363!.gitignore
364`
365 if err := os.WriteFile(gitignorePath, []byte(gitignoreContent), constants.FilePermSensitive); err != nil {
366 return "", fmt.Errorf("failed to write %s: %w", gitignorePath, err)
367 }
368 return updatesDir, nil
369}
370
371func shallowCloneTargetRepo(ctx context.Context, repo, destination string) error {
372 if err := os.RemoveAll(destination); err != nil {

Callers 5

runUpdateForTargetRepoFunction · 0.85
prepareDeployCheckoutFunction · 0.85
scanUpgradeRepoFunction · 0.85
runUpgradeForTargetRepoFunction · 0.85
previewOrgRepoUpdatesFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected