mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-03 16:22:40 +00:00
Copy hooks and config files on fork
This commit is contained in:
parent
8998e46fea
commit
5bfd40f9fd
2 changed files with 33 additions and 24 deletions
|
@ -33,32 +33,12 @@ func InitRepository(user string, gist string) error {
|
|||
repositoryPath,
|
||||
)
|
||||
|
||||
_, err := cmd.Output()
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f1, err := os.OpenFile(filepath.Join(repositoryPath, "git-daemon-export-ok"), os.O_RDONLY|os.O_CREATE, 0644)
|
||||
defer f1.Close()
|
||||
|
||||
preReceiveDst, err := os.OpenFile(filepath.Join(repositoryPath, "hooks", "pre-receive"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
preReceiveSrc, err := os.OpenFile(filepath.Join("internal", "resources", "pre-receive"), os.O_RDONLY, os.ModeAppend)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(preReceiveDst, preReceiveSrc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer preReceiveDst.Close()
|
||||
defer preReceiveSrc.Close()
|
||||
|
||||
return err
|
||||
return copyFiles(repositoryPath)
|
||||
}
|
||||
|
||||
func GetNumberOfCommitsOfRepository(user string, gist string) (string, error) {
|
||||
|
@ -189,7 +169,12 @@ func ForkClone(userSrc string, gistSrc string, userDst string, gistDst string) e
|
|||
|
||||
cmd = exec.Command("git", "config", "user.name", userDst)
|
||||
cmd.Dir = repositoryPathDst
|
||||
return cmd.Run()
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return copyFiles(repositoryPathDst)
|
||||
}
|
||||
|
||||
func SetFileContent(gistTmpId string, filename string, content string) error {
|
||||
|
@ -274,3 +259,27 @@ func GetGitVersion() (string, error) {
|
|||
|
||||
return versionFields[2], nil
|
||||
}
|
||||
|
||||
func copyFiles(repositoryPath string) error {
|
||||
f1, err := os.OpenFile(filepath.Join(repositoryPath, "git-daemon-export-ok"), os.O_RDONLY|os.O_CREATE, 0644)
|
||||
defer f1.Close()
|
||||
|
||||
preReceiveDst, err := os.OpenFile(filepath.Join(repositoryPath, "hooks", "pre-receive"), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
preReceiveSrc, err := os.OpenFile(filepath.Join("internal", "resources", "pre-receive"), os.O_RDONLY, os.ModeAppend)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(preReceiveDst, preReceiveSrc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer preReceiveDst.Close()
|
||||
defer preReceiveSrc.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func Start() {
|
|||
return nil
|
||||
},
|
||||
}))
|
||||
//e.Use(middleware.Recover())
|
||||
e.Use(middleware.Recover())
|
||||
e.Use(middleware.Secure())
|
||||
|
||||
e.Renderer = &Template{
|
||||
|
|
Loading…
Reference in a new issue