From 7f25d92377448e2e696d89e783ded0eea818a236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Ri=C3=9Fe?= Date: Mon, 17 Mar 2025 09:58:47 +0000 Subject: [PATCH] fix: set git identity for p2phttp processes (#70) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Fixes #69. ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo-aneksajo/forgejo-aneksajo/pulls/70 Co-authored-by: Matthias Riße Co-committed-by: Matthias Riße --- routers/web/repo/annex.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routers/web/repo/annex.go b/routers/web/repo/annex.go index 852b5a11cc..d696a35100 100644 --- a/routers/web/repo/annex.go +++ b/routers/web/repo/annex.go @@ -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)