fix: set git identity for p2phttp processes

In some situations it could happen that `git annex p2phttp` needs some
kind of maintenance work resulting in a commit, but without a configured
git identity p2phttp would refuse to run. This could break p2phttp
support.

Setting `GIT_AUTHOR_{NAME,EMAIL}` should remedy this issue.
This commit is contained in:
Matthias Riße 2025-03-14 15:48:29 +01:00
parent 6c61f80d21
commit 7a62ee693f

View file

@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/annex"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
services_context "code.gitea.io/gitea/services/context"
)
@ -93,6 +94,10 @@ func AnnexP2PHTTP(ctx *services_context.Context) {
Pdeathsig: syscall.SIGINT,
}
cmd.Cancel = func() error { return cmd.Process.Signal(os.Interrupt) }
cmd.Env = append(os.Environ(),
"GIT_AUTHOR_NAME="+setting.AppName,
"GIT_AUTHOR_EMAIL="+setting.RunUser+"@"+setting.Domain,
)
_ = cmd.Run()
}(p2phttpCtx)
graceful.GetManager().RunAtTerminate(p2phttpCtxCancel)