1
0
mirror of https://github.com/thomiceli/opengist synced 2024-11-08 12:55:50 +01:00

Fix bug on undefined commiter name

This commit is contained in:
Thomas Miceli 2023-04-04 02:01:31 +02:00
parent 746d836b99
commit 5638bf7601
No known key found for this signature in database
GPG Key ID: D86C6F6390AF050F
2 changed files with 14 additions and 2 deletions

@ -129,7 +129,7 @@ func GetLog(user string, gist string, skip string) ([]*Commit, error) {
return parseLog(stdout), nil
}
func CloneTmp(user string, gist string, gistTmpId string) error {
func CloneTmp(user string, gist string, gistTmpId string, email string) error {
repositoryPath := RepositoryPath(user, gist)
tmpPath := TmpRepositoriesPath()
@ -150,6 +150,18 @@ func CloneTmp(user string, gist string, gistTmpId string) error {
// remove every file (and not the .git directory!)
cmd = exec.Command("find", ".", "-maxdepth", "1", "-type", "f", "-delete")
cmd.Dir = tmpRepositoryPath
if err = cmd.Run(); err != nil {
return err
}
cmd = exec.Command("git", "config", "--local", "user.name", user)
cmd.Dir = tmpRepositoryPath
if err = cmd.Run(); err != nil {
return err
}
cmd = exec.Command("git", "config", "--local", "user.email", email)
cmd.Dir = tmpRepositoryPath
return cmd.Run()
}

@ -237,7 +237,7 @@ func (gist *Gist) NbCommits() (string, error) {
}
func (gist *Gist) AddAndCommitFiles(files *[]FileDTO) error {
if err := git.CloneTmp(gist.User.Username, gist.Uuid, gist.Uuid); err != nil {
if err := git.CloneTmp(gist.User.Username, gist.Uuid, gist.Uuid, gist.User.Email); err != nil {
return err
}