Add 2 new admin actions (#191)

* Synchronize all gists previews
* Reset Git server hooks for all repositories
This commit is contained in:
Thomas Miceli
2024-01-02 04:01:45 +01:00
parent 97707f7cca
commit f52310a841
10 changed files with 213 additions and 86 deletions

View File

@ -77,7 +77,7 @@ func InitRepository(user string, gist string) error {
return err
}
return createDotGitFiles(repositoryPath)
return CreateDotGitFiles(user, gist)
}
func InitRepositoryViaInit(user string, gist string, ctx echo.Context) error {
@ -371,7 +371,7 @@ func ForkClone(userSrc string, gistSrc string, userDst string, gistDst string) e
return err
}
return createDotGitFiles(repositoryPathDst)
return CreateDotGitFiles(userDst, gistDst)
}
func SetFileContent(gistTmpId string, filename string, content string) error {
@ -525,7 +525,9 @@ func GetGitVersion() (string, error) {
return versionFields[2], nil
}
func createDotGitFiles(repositoryPath string) error {
func CreateDotGitFiles(user string, gist string) error {
repositoryPath := RepositoryPath(user, gist)
f1, err := os.OpenFile(filepath.Join(repositoryPath, "git-daemon-export-ok"), os.O_RDONLY|os.O_CREATE, 0644)
if err != nil {
return err
@ -540,7 +542,7 @@ func createDotGitFiles(repositoryPath string) error {
}
func createDotGitHookFile(repositoryPath string, hook string, content string) error {
preReceiveDst, err := os.OpenFile(filepath.Join(repositoryPath, "hooks", hook), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0744)
preReceiveDst, err := os.OpenFile(filepath.Join(repositoryPath, "hooks", hook), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0744)
if err != nil {
return err
}