diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-07-05 12:15:57 +0300 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-07-05 12:15:57 +0300 |
commit | ece1163bfe8e3997ce21fa19b1c82d77472ee063 (patch) | |
tree | 91466f83e555acd5c46a6d2191d3e4a6f4d54da3 | |
parent | 57f976e4e7f92c39869af37ec5fbd1c2dbf2d3fb (diff) | |
parent | 0ded00b9dcb1641e10280e8c87b83e537d010cf3 (diff) |
Merge branch '143-inherit-tz' into 'master'
Inherit the TZ environment variable
See merge request !201
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | internal/helper/command.go | 1 | ||||
-rw-r--r-- | internal/helper/command_test.go | 35 |
3 files changed, 41 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eded313c..960b6eeb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Gitaly changelog +UNRELEASED + +- Ensure that sub-processes inherit TZ environment variable + https://gitlab.com/gitlab-org/gitaly/merge_requests/201 + v0.14.0 - Added integration test for SSH, and a client package diff --git a/internal/helper/command.go b/internal/helper/command.go index 61d672a91..d66eed92a 100644 --- a/internal/helper/command.go +++ b/internal/helper/command.go @@ -34,6 +34,7 @@ func NewCommand(cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.Writer, env .. fmt.Sprintf("HOME=%s", os.Getenv("HOME")), fmt.Sprintf("PATH=%s", os.Getenv("PATH")), fmt.Sprintf("LD_LIBRARY_PATH=%s", os.Getenv("LD_LIBRARY_PATH")), + fmt.Sprintf("TZ=%s", os.Getenv("TZ")), } cmd.Env = append(cmd.Env, env...) diff --git a/internal/helper/command_test.go b/internal/helper/command_test.go new file mode 100644 index 000000000..58192a69c --- /dev/null +++ b/internal/helper/command_test.go @@ -0,0 +1,35 @@ +package helper + +import ( + "bytes" + "os" + "os/exec" + "testing" +) + +func TestNewCommand_Env(t *testing.T) { + oldTZ := os.Getenv("TZ") + defer os.Setenv("TZ", oldTZ) + + os.Setenv("TZ", "foobar") + + buff := &bytes.Buffer{} + cmd, err := NewCommand(exec.Command("env"), nil, buff, nil) + if err != nil { + t.Fatal(err) + } + if err = cmd.Wait(); err != nil { + t.Fatal(err) + } + + found := false + split := bytes.Split(buff.Bytes(), []byte("\n")) + for _, line := range split { + if bytes.Compare(line, []byte("TZ=foobar")) == 0 { + found = true + } + } + if !found { + t.Errorf("TZ not set to `foobar`") + } +} |