mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-23 04:52:40 +00:00
Adapt find command for Windows users (#89)
This commit is contained in:
parent
3943b53163
commit
6085471b81
1 changed files with 16 additions and 3 deletions
|
@ -199,9 +199,7 @@ func CloneTmp(user string, gist string, gistTmpId string, email string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove every file (and not the .git directory!)
|
// remove every file (and not the .git directory!)
|
||||||
cmd = exec.Command("find", ".", "-maxdepth", "1", "-type", "f", "-delete")
|
if err = removeFilesExceptGit(tmpRepositoryPath); err != nil {
|
||||||
cmd.Dir = tmpRepositoryPath
|
|
||||||
if err = cmd.Run(); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +405,21 @@ func createDotGitHookFile(repositoryPath string, hook string, content string) er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeFilesExceptGit(dir string) error {
|
||||||
|
return filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if d.IsDir() && filepath.Base(path) == ".git" {
|
||||||
|
return filepath.SkipDir
|
||||||
|
}
|
||||||
|
if !d.IsDir() {
|
||||||
|
return os.Remove(path)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const preReceive = `#!/bin/sh
|
const preReceive = `#!/bin/sh
|
||||||
|
|
||||||
disallowed_files=""
|
disallowed_files=""
|
||||||
|
|
Loading…
Reference in a new issue