MCPcopy Index your code
hub / github.com/redspread/spread / TempWorkdir

Method TempWorkdir

pkg/project/workdir.go:12–28  ·  view source on GitHub ↗

TempWorkdir creates a temporary directory and configures the Repository to use it as a work dir. HEAD is checked out to the temporary working directory. The path of the working directory is returned as a string.

()

Source from the content-addressed store, hash-verified

10// TempWorkdir creates a temporary directory and configures the Repository to use it as a work dir.
11// HEAD is checked out to the temporary working directory. The path of the working directory is returned as a string.
12func (p *Project) TempWorkdir() (string, error) {
13 name, err := ioutil.TempDir("", "spread-workdir")
14 if err != nil {
15 return "", err
16 }
17
18 opts := &git.CheckoutOpts{
19 TargetDirectory: name,
20 }
21
22 if err = p.repo.CheckoutHead(opts); err != nil {
23 os.RemoveAll(name)
24 return "", err
25 }
26
27 return name, p.repo.SetWorkdir(name, false)
28}
29
30// CleanupWorkdir removes the given directory and sets the repositories Workdir to an empty string.
31func (p *Project) CleanupWorkdir(dir string) error {

Callers 1

PullMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected