Comparing version 0.0.3 to 0.0.4
@@ -17,28 +17,20 @@ var crypto = require('crypto'); | ||
var prepareHashInfo = function(repoOwner, repoName, branch, settings, user) { | ||
var prepareHashInfo = function(repoOwner, repoName, branch, latestSha, settings) { | ||
var build_sh = ""; | ||
var start_sh = ""; | ||
var useDockerfileFromRepo = false; | ||
return Q() | ||
.then(function () { | ||
if (settings) { | ||
build_sh = settings.build_sh || build_sh; | ||
start_sh = settings.start_sh || start_sh; | ||
useDockerfileFromRepo = settings.useDockerfileFromRepo; | ||
} | ||
var build_sh = ""; | ||
var start_sh = ""; | ||
var useDockerfileFromRepo = false; | ||
//the revision marker may or may not include information... that depends on the use case. | ||
//if we don't use the dockerfile from the repo - we have a single image per repo. | ||
//no need to create a sha for every branch. | ||
//if we do use the dockerfile from the repo - we can't optimize, we have to build each time. | ||
//we need a sha for every branch. | ||
var revisionMarkerPromise = Q(''); //jshint ignore:line | ||
if (useDockerfileFromRepo) { | ||
revisionMarkerPromise = revisionMarkerPromise.then(function () { | ||
return getLatestSha(user, repoOwner, repoName, branch); | ||
}); | ||
} | ||
if (settings) { | ||
build_sh = settings.build_sh || build_sh; | ||
start_sh = settings.start_sh || start_sh; | ||
useDockerfileFromRepo = settings.useDockerfileFromRepo; | ||
} | ||
return revisionMarkerPromise | ||
.then(function (revisionMarker) { | ||
//if we use customer dockerfile, we don't have an image per repo, we have an image per sha. | ||
var revisionInfoIfRelevant = useDockerfileFromRepo ? latestSha : ''; | ||
var hash = crypto.createHash('sha1'); | ||
@@ -49,3 +41,3 @@ hash.update( | ||
JSON.stringify(useDockerfileFromRepo) + | ||
revisionMarker); | ||
revisionInfoIfRelevant); | ||
@@ -52,0 +44,0 @@ var buildHash = hash.digest('hex').replace(/-/g, '_').toLowerCase(); |
{ | ||
"name": "cf-common", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "common modules for codefresh runtime and api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
2261
49