@@ -50,7 +50,7 @@ function restAPICall(method, url, headers, cb) {
5050 req . end ( ) ;
5151}
5252
53- function getDeployedHashes ( environments , cb ) {
53+ function getDeployedVersions ( environments , cb ) {
5454 const hashes = [ ] ;
5555 const envFound = new Array ( environments ? environments . length : 2 ) . fill ( false ) ;
5656 let pending = 1 ;
@@ -72,7 +72,7 @@ function getDeployedHashes(environments, cb) {
7272 return ;
7373 }
7474 if ( statuses [ 0 ] && statuses [ 0 ] . state == 'success' ) {
75- hashes . push ( deployment . sha ) ;
75+ hashes . push ( deployment . payload . version ) ;
7676 envFound [ index ] = true ;
7777 }
7878 if ( ! -- pending && cb ) {
@@ -128,16 +128,12 @@ function maybeDeleteDroplet(providerTag, name, birthDate, del) {
128128// Why: every build produces an image
129129let maybeDeleteImage = ( function ( ) {
130130 const pending = [ ] ;
131- getDeployedHashes ( [ 'production' ] , ( err , hashes ) => {
131+ getDeployedVersions ( [ 'production' ] , ( err , versions ) => {
132132 if ( err ) fatal ( 'get deployed hashes:' , err ) ;
133133 function isOrphanedImage ( name ) {
134134 if ( ! name . startsWith ( 'image-' ) )
135135 return false ;
136- const res = child_process . spawnSync (
137- 'git' , [ 'rev-parse' , '--verify' , 'v' + name . substr ( 6 ) ] ,
138- { encoding : 'utf8' }
139- ) ;
140- return res . status || ! hashes . includes ( res . stdout . trim ( ) ) ;
136+ return ! versions . includes ( name . substr ( 6 ) ) ;
141137 }
142138 maybeDeleteImage = function ( providerTag , name , birthDate , del ) {
143139 if ( isOrphanedImage ( name ) && ageInHours ( birthDate ) > .5 ) {
0 commit comments