MCPcopy Create free account
hub / github.com/cli/cli / snapshotGit

Method snapshotGit

script/ghmock/gitfixture.go:65–84  ·  view source on GitHub ↗
(runID, in string)

Source from the content-addressed store, hash-verified

63}
64
65func (s *state) snapshotGit(runID, in string) (string, error) {
66 _, err := os.Stat(s.gitFixtureDir())
67 if errors.Is(err, fs.ErrNotExist) {
68 if in != "" {
69 return "", fmt.Errorf("no Git fixture yet; prepare it with ghmock repo, git or write")
70 }
71 return "", nil
72 }
73 if err != nil {
74 return "", err
75 }
76 if _, err := gitWorkDir(s.gitFixtureDir(), in); err != nil {
77 return "", err
78 }
79 relative := filepath.Join("git", "runs", runID, "before")
80 if err := copyGitTree(s.gitFixtureDir(), filepath.Join(s.dir, relative)); err != nil {
81 return "", fmt.Errorf("snapshotting Git fixture: %w", err)
82 }
83 return filepath.ToSlash(relative), nil
84}
85
86func gitWorkDir(world, in string) (string, error) {
87 if in == "" {

Callers 1

runAllFunction · 0.80

Calls 5

gitFixtureDirMethod · 0.95
gitWorkDirFunction · 0.85
copyGitTreeFunction · 0.85
JoinMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected