From 50236966d0ab891b40291de3c385f12cbaf8126c Mon Sep 17 00:00:00 2001 From: "derks.patrick" Date: Thu, 15 Apr 2021 18:39:19 +0200 Subject: [PATCH] add function for checking requirements changes --- api/tasks/runner.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/tasks/runner.go b/api/tasks/runner.go index f5c5b5ad..e53af43f 100644 --- a/api/tasks/runner.go +++ b/api/tasks/runner.go @@ -537,6 +537,20 @@ func (t *task) envVars(home string, pwd string, gitSSHCommand *string) []string return env } +func hasRequirementsChanges(requirementsFilePath string, requirementsHashFilePath string) bool { + oldFileMD5HashBytes, err := ioutil.ReadFile(requirementsHashFilePath) + if err != nil { + return true + } + + newFileMD5Hash, err := helpers.GetMD5Hash(requirementsFilePath) + if err != nil { + return true + } + + return string(oldFileMD5HashBytes) != newFileMD5Hash +} + // extractCommandEnvironment unmarshalls a json string, extracts the ENV key from it and returns it as // []string where strings are in key=value format func extractCommandEnvironment(envJSON string) []string {