diff options
author | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-07-05 18:13:46 +0300 |
---|---|---|
committer | Jacob Vosmaer (GitLab) <jacob@gitlab.com> | 2017-07-05 18:13:46 +0300 |
commit | c9dd522c4868e4db6f73d38d7c6672fce4848006 (patch) | |
tree | fd4deceff095674ea3690e4ff14eb6f446e5b35a | |
parent | 537f9ae878ebac20218e0e5640318e512ed2b478 (diff) | |
parent | ece1163bfe8e3997ce21fa19b1c82d77472ee063 (diff) |
Merge branch 'master' into '315-conversation-commits_between'
# Conflicts:
# CHANGELOG.md
-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, 40 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 879da6dca..c410525bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Gitaly changelog -v0.15.0 +UNRELEASED + +- Ensure that sub-processes inherit TZ environment variable + https://gitlab.com/gitlab-org/gitaly/merge_requests/201 - Implement CommitService::CommitsBetween https://gitlab.com/gitlab-org/gitaly/merge_requests/197 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`") + } +} |