mirror of
https://github.com/moby/buildkit.git
synced 2026-08-12 22:16:54 +00:00
Add git.mtime=commit option that normalizes all file, symlink, and directory mtimes in a git snapshot to the resolved commit timestamp. This enables reproducible builds from git sources. When SOURCE_DATE_EPOCH is set in the Dockerfile frontend, the git context automatically uses commit-time mtimes. The URL query parameter ?mtime=commit|checkout can override this. New LLB attr (git.mtime) and capability (source.git.mtime) are registered as experimental. Cache keys include the mtime policy so that commit-time and checkout-time snapshots are distinct. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
15 lines
269 B
Go
15 lines
269 B
Go
//go:build !windows
|
|
|
|
package git
|
|
|
|
import (
|
|
"time"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func lchtimes(path string, t time.Time) error {
|
|
ts := unix.NsecToTimespec(t.UnixNano())
|
|
return unix.UtimesNanoAt(unix.AT_FDCWD, path, []unix.Timespec{ts, ts}, unix.AT_SYMLINK_NOFOLLOW)
|
|
}
|