MCPcopy Index your code
hub / github.com/coder/coder / makeMigrateFS

Function makeMigrateFS

scripts/migrate-test/main.go:117–134  ·  view source on GitHub ↗
(version string)

Source from the content-addressed store, hash-verified

115}
116
117func makeMigrateFS(version string) (fs.FS, error) {
118 // Export the migrations from the requested version to a zip archive
119 out, err := exec.Command("git", "archive", "--format=zip", version, "coderd/database/migrations").CombinedOutput()
120 if err != nil {
121 return nil, xerrors.Errorf("git archive: %s\n", out)
122 }
123 // Make a zip.Reader on top of it. This implements fs.fs!
124 zr, err := zip.NewReader(bytes.NewReader(out), int64(len(out)))
125 if err != nil {
126 return nil, xerrors.Errorf("create zip reader: %w", err)
127 }
128 // Sub-FS to it's rooted at migrations dir.
129 subbed, err := fs.Sub(zr, "coderd/database/migrations")
130 if err != nil {
131 return nil, xerrors.Errorf("sub fs: %w", err)
132 }
133 return subbed, nil
134}
135
136func gitShow(path, version string) ([]byte, error) {
137 out, err := exec.Command("git", "show", version+":"+path).CombinedOutput() //nolint:gosec

Callers 1

mainFunction · 0.85

Calls 2

CommandMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected