From d39e756e7c8673c160cb45eae7885fe2378c720a Mon Sep 17 00:00:00 2001 From: Mujib Ahasan Date: Fri, 6 Mar 2026 01:48:52 +0530 Subject: [PATCH 1/4] helm history respect TZ now Signed-off-by: Mujib Ahasan --- pkg/cmd/history.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/cmd/history.go b/pkg/cmd/history.go index f53a2f1a6..31d7a8736 100644 --- a/pkg/cmd/history.go +++ b/pkg/cmd/history.go @@ -194,7 +194,7 @@ func (r releaseHistory) WriteTable(out io.Writer) error { tbl := uitable.New() tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART", "APP VERSION", "DESCRIPTION") for _, item := range r { - tbl.AddRow(item.Revision, item.Updated.Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) + tbl.AddRow(item.Revision, item.Updated.In(time.Local).Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, item.Description) } return output.EncodeTable(out, tbl) } From a26c707faa36363111ad2cf6bc47a860383085fa Mon Sep 17 00:00:00 2001 From: Mujib Ahasan Date: Fri, 6 Mar 2026 02:36:28 +0530 Subject: [PATCH 2/4] test cases fixed for helm history Signed-off-by: Mujib Ahasan --- pkg/cmd/helpers_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index 3db5f38ab..c44fcf466 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -49,6 +49,8 @@ func init() { func runTestCmd(t *testing.T, tests []cmdTestCase) { t.Helper() + t.Setenv("TZ", "UTC") + time.Local = time.UTC for _, tt := range tests { for i := 0; i <= tt.repeat; i++ { t.Run(tt.name, func(t *testing.T) { From b972701ebea6f94eef41b7442a43ad4e3dd9f55b Mon Sep 17 00:00:00 2001 From: Mujib Ahasan Date: Wed, 11 Mar 2026 01:12:00 +0530 Subject: [PATCH 3/4] update: helper now save previous time.local value and restore it Signed-off-by: Mujib Ahasan --- pkg/cmd/helpers_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cmd/helpers_test.go b/pkg/cmd/helpers_test.go index c44fcf466..b31fb8088 100644 --- a/pkg/cmd/helpers_test.go +++ b/pkg/cmd/helpers_test.go @@ -50,6 +50,10 @@ func init() { func runTestCmd(t *testing.T, tests []cmdTestCase) { t.Helper() t.Setenv("TZ", "UTC") + prevLocal := time.Local + t.Cleanup(func() { + time.Local = prevLocal + }) time.Local = time.UTC for _, tt := range tests { for i := 0; i <= tt.repeat; i++ { From ab5209a9e75248b8c6259b504ee45a0777988c93 Mon Sep 17 00:00:00 2001 From: Mujib Ahasan Date: Wed, 15 Jul 2026 23:58:50 +0530 Subject: [PATCH 4/4] test case added Signed-off-by: Mujib Ahasan --- pkg/cmd/history.go | 2 +- pkg/cmd/history_test.go | 89 +++++++++++++++++++ .../output/history-timezone-with-rollback.txt | 4 + pkg/cmd/testdata/output/history-timezone.txt | 4 + 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 pkg/cmd/testdata/output/history-timezone-with-rollback.txt create mode 100644 pkg/cmd/testdata/output/history-timezone.txt diff --git a/pkg/cmd/history.go b/pkg/cmd/history.go index 31d7a8736..16cec1b12 100644 --- a/pkg/cmd/history.go +++ b/pkg/cmd/history.go @@ -218,7 +218,7 @@ func (r releaseHistoryWithRollback) WriteTable(out io.Writer) error { if item.RollbackRevision > 0 { rollback = strconv.Itoa(item.RollbackRevision) } - tbl.AddRow(item.Revision, item.Updated.Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, rollback, item.Description) + tbl.AddRow(item.Revision, item.Updated.In(time.Local).Format(time.ANSIC), item.Status, item.Chart, item.AppVersion, rollback, item.Description) } return output.EncodeTable(out, tbl) } diff --git a/pkg/cmd/history_test.go b/pkg/cmd/history_test.go index 2bace98e0..69af197a2 100644 --- a/pkg/cmd/history_test.go +++ b/pkg/cmd/history_test.go @@ -26,6 +26,8 @@ import ( "github.com/stretchr/testify/require" chart "helm.sh/helm/v4/pkg/chart/v2" + + "helm.sh/helm/v4/internal/test" "helm.sh/helm/v4/pkg/release/common" release "helm.sh/helm/v4/pkg/release/v1" ) @@ -148,6 +150,93 @@ func TestHistoryWithRollback(t *testing.T) { runTestCmd(t, tests) } +func TestHistoryCmdRespectsTimezone(t *testing.T) { + location := time.FixedZone("UTC-4", -4*60*60) + + prevLocal := time.Local + time.Local = location + t.Cleanup(func() { + time.Local = prevLocal + }) + + date := time.Unix(242085845, 0).UTC() + ch := &chart.Chart{ + Metadata: &chart.Metadata{ + Name: "foo", + Version: "0.1.0-beta.1", + AppVersion: "1.0", + }, + } + + releases := []*release.Release{ + { + Name: "angry-bird", + Version: 1, + Info: &release.Info{ + FirstDeployed: date, + LastDeployed: date, + Status: common.StatusSuperseded, + Description: "Install complete", + }, + Chart: ch, + }, + { + Name: "angry-bird", + Version: 2, + Info: &release.Info{ + FirstDeployed: date, + LastDeployed: date, + Status: common.StatusSuperseded, + Description: "Upgrade complete", + }, + Chart: ch, + }, + { + Name: "angry-bird", + Version: 3, + Info: &release.Info{ + FirstDeployed: date, + LastDeployed: date, + Status: common.StatusDeployed, + RollbackRevision: 1, + Description: "Rollback to 1", + }, + Chart: ch, + }, + } + + tests := []struct { + name string + command string + golden string + }{ + { + name: "default table", + command: "history angry-bird", + golden: "output/history-timezone.txt", + }, + { + name: "rollback revision table", + command: "history angry-bird --show-rollback-revision", + golden: "output/history-timezone-with-rollback.txt", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + storage := storageFixture() + for _, rel := range releases { + require.NoError(t, storage.Create(rel)) + } + + _, out, err := executeActionCommandC(storage, tt.command) + require.NoError(t, err) + + test.AssertGoldenString(t, out, tt.golden) + }) + } +} + func TestHistoryOutputCompletion(t *testing.T) { outputFlagCompletionTest(t, "history") } diff --git a/pkg/cmd/testdata/output/history-timezone-with-rollback.txt b/pkg/cmd/testdata/output/history-timezone-with-rollback.txt new file mode 100644 index 000000000..84096ca64 --- /dev/null +++ b/pkg/cmd/testdata/output/history-timezone-with-rollback.txt @@ -0,0 +1,4 @@ +REVISION UPDATED STATUS CHART APP VERSION ROLLBACK DESCRIPTION +1 Fri Sep 2 18:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Install complete +2 Fri Sep 2 18:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Upgrade complete +3 Fri Sep 2 18:04:05 1977 deployed foo-0.1.0-beta.1 1.0 1 Rollback to 1 diff --git a/pkg/cmd/testdata/output/history-timezone.txt b/pkg/cmd/testdata/output/history-timezone.txt new file mode 100644 index 000000000..5053f28ec --- /dev/null +++ b/pkg/cmd/testdata/output/history-timezone.txt @@ -0,0 +1,4 @@ +REVISION UPDATED STATUS CHART APP VERSION DESCRIPTION +1 Fri Sep 2 18:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Install complete +2 Fri Sep 2 18:04:05 1977 superseded foo-0.1.0-beta.1 1.0 Upgrade complete +3 Fri Sep 2 18:04:05 1977 deployed foo-0.1.0-beta.1 1.0 Rollback to 1