From d7eefe6835938cb4be7e2403a781c5c6872abd3f Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Mon, 27 Sep 2021 18:34:56 -0700 Subject: [PATCH] CAPROVER_GIT_COMMIT_SHA for Method 3 - fixed https://github.com/caprover/caprover/issues/1198 --- src/user/ImageMaker.ts | 12 ++++++++++++ src/user/ServiceManager.ts | 14 -------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/user/ImageMaker.ts b/src/user/ImageMaker.ts index 608023c..943f5b6 100644 --- a/src/user/ImageMaker.ts +++ b/src/user/ImageMaker.ts @@ -123,6 +123,18 @@ export default class ImageMaker { }) .then(function (gitHashFromImageSource) { gitHash = gitHashFromImageSource + + const includesGitCommitEnvVar = envVars.find( + (envVar) => envVar.key === CaptainConstants.gitShaEnvVarKey + ) + + if (gitHash && !includesGitCommitEnvVar) { + envVars.push({ + key: CaptainConstants.gitShaEnvVarKey, + value: gitHash, + }) + } + // some users convert the directory into TAR instead of converting the content into TAR. // we go one level deep and try to find the right directory. // Also, they may have no captain-definition file, in that case, fall back to Dockerfile if exists. diff --git a/src/user/ServiceManager.ts b/src/user/ServiceManager.ts index b5bac69..f61b60a 100644 --- a/src/user/ServiceManager.ts +++ b/src/user/ServiceManager.ts @@ -169,20 +169,6 @@ class ServiceManager { .then(function (app) { const envVars = app.envVars || [] - const includesGitCommitEnvVar = envVars.find( - (envVar) => - envVar.key === CaptainConstants.gitShaEnvVarKey - ) - const gitHash = - source.captainDefinitionContentSource?.gitHash || - source.uploadedTarPathSource?.gitHash - if (gitHash && !includesGitCommitEnvVar) { - envVars.push({ - key: CaptainConstants.gitShaEnvVarKey, - value: gitHash, - }) - } - return self.imageMaker.ensureImage( source, appName,