From 92f9b72be5683bbfb24d2222d2bc0693f6b58e05 Mon Sep 17 00:00:00 2001 From: Andrei Boar Date: Mon, 19 Dec 2022 11:57:04 +0200 Subject: [PATCH] ignore extra env variables for task input hash --- bobtask/task.go | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/bobtask/task.go b/bobtask/task.go index 932bf087..ba45c31e 100644 --- a/bobtask/task.go +++ b/bobtask/task.go @@ -192,12 +192,7 @@ func (t *Task) description() string { // env is influenced by t.dependencies, so no need to hash t.dependencies sort.Strings(t.env) for _, v := range t.env { - // ignore buildCommandPath and SHLVL due to non-reproducibility - v = strings.ToLower(v) - if strings.HasPrefix(v, "buildcommandpath=") { - continue - } - if strings.HasPrefix(v, "shlvl=") { + if shouldIgnore(v) { continue } sb.WriteString(v) @@ -214,3 +209,28 @@ func (t *Task) description() string { return sb.String() } + +// shouldIgnore checks if the key-value env pair +// should be ignored from the task description due to non-reproducibility +func shouldIgnore(v string) bool { + v = strings.ToLower(v) + if strings.HasPrefix(v, "buildcommandpath=") { + return true + } + if strings.HasPrefix(v, "shlvl=") { + return true + } + if strings.HasPrefix(v, "home=") { + return true + } + if strings.HasPrefix(v, "logname=") { + return true + } + if strings.HasPrefix(v, "pwd=") { + return true + } + if strings.HasPrefix(v, "user=") { + return true + } + return false +}