From e1ebfdad10ef98fe6c9d424efe3f97d7b2322f04 Mon Sep 17 00:00:00 2001 From: Oscar Linderholm Date: Tue, 30 Jan 2024 11:59:30 +0100 Subject: [PATCH] fix: honor SOURCE_DATE_EPOCH for files (#775) If set, SOURCE_DATE_EPOCH will be honored for all content entries. --- files/files.go | 2 +- files/files_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/files/files.go b/files/files.go index 7c0d3ac1..c8f462a2 100644 --- a/files/files.go +++ b/files/files.go @@ -128,7 +128,7 @@ func (c *Content) WithFileInfoDefaults(umask fs.FileMode, mtime time.Time) *Cont if (cc.Type == TypeDir || cc.Type == TypeImplicitDir) && cc.FileInfo.Mode == 0 { cc.FileInfo.Mode = 0o755 } - if (cc.Type == TypeDir || cc.Type == TypeImplicitDir) && cc.FileInfo.MTime.IsZero() { + if cc.FileInfo.MTime.IsZero() { cc.FileInfo.MTime = mtime } diff --git a/files/files_test.go b/files/files_test.go index 3f025059..d6c45dce 100644 --- a/files/files_test.go +++ b/files/files_test.go @@ -160,7 +160,7 @@ contents: require.Equal(t, "files_test.go", f.Source) require.Equal(t, "/b", f.Destination) require.Equal(t, f.FileInfo.Mode, fi.Mode()) - require.Equal(t, f.FileInfo.MTime, fi.ModTime()) + require.Equal(t, f.FileInfo.MTime, mtime) } func TestFileInfo(t *testing.T) {