[PR #3772] [CLOSED] avoid os.Setenv calls in runServ, add env vars to gitcmd.Env instead #17075

Closed
opened 2025-11-02 12:25:43 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3772
Author: @ilius
Created: 4/9/2018
Status: Closed

Base: masterHead: PR-serv-Setenv


📝 Commits (3)

  • ca10494 avoid os.Setenv calls in runServ, add env vars to gitcmd.Env instead
  • a24f52b cmd/serv.go: use a string slice instead of map for keeping env vars
  • 5817c2e Merge branch 'master' into PR-serv-Setenv

📊 Changes

1 file changed (+13 additions, -7 deletions)

View changed files

📝 cmd/serv.go (+13 -7)

📄 Description

Using os.Setenv() is the middle of a running program is very unsafe, specially if some vars are set conditionally (their effect will remain until the program is running)

I think the only reason we set these env vars is because of running the git command gitcmd.Run().
Please correct me if I'm wrong.
For the gitcmd.Run(), we just need to add vars to gitcmd.Env, without effecting the global env vars.

EDIT: I realized this part of program does not stay running (and there is no concurrency) because it's compiled to a serv binary and runs for each operation.
But it's still cleaner this way and a better practice in general.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3772 **Author:** [@ilius](https://github.com/ilius) **Created:** 4/9/2018 **Status:** ❌ Closed **Base:** `master` ← **Head:** `PR-serv-Setenv` --- ### 📝 Commits (3) - [`ca10494`](https://github.com/go-gitea/gitea/commit/ca10494f4af747f5dc9ada8908281840e82344af) avoid os.Setenv calls in runServ, add env vars to gitcmd.Env instead - [`a24f52b`](https://github.com/go-gitea/gitea/commit/a24f52b0652b9999662d2afd2a47c3ead6a31370) cmd/serv.go: use a string slice instead of map for keeping env vars - [`5817c2e`](https://github.com/go-gitea/gitea/commit/5817c2e3e4b8cc91671ae366dc650a3880753739) Merge branch 'master' into PR-serv-Setenv ### 📊 Changes **1 file changed** (+13 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `cmd/serv.go` (+13 -7) </details> ### 📄 Description Using `os.Setenv()` is the middle of a running program is very unsafe, specially if some vars are set conditionally (their effect will remain until the program is running) I think the only reason we set these env vars is because of running the git command `gitcmd.Run()`. Please correct me if I'm wrong. For the `gitcmd.Run()`, we just need to add vars to `gitcmd.Env`, without effecting the global env vars. EDIT: I realized this part of program does not stay running (and there is no concurrency) because it's compiled to a `serv` binary and runs for each operation. But it's still cleaner this way and a better practice in general. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:25:43 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#17075