@@ -50,7 +50,7 @@ function restAPICall(method, url, headers, cb) {
50
50
req . end ( ) ;
51
51
}
52
52
53
- function getDeployedHashes ( environments , cb ) {
53
+ function getDeployedVersions ( environments , cb ) {
54
54
const hashes = [ ] ;
55
55
const envFound = new Array ( environments ? environments . length : 2 ) . fill ( false ) ;
56
56
let pending = 1 ;
@@ -72,7 +72,7 @@ function getDeployedHashes(environments, cb) {
72
72
return ;
73
73
}
74
74
if ( statuses [ 0 ] && statuses [ 0 ] . state == 'success' ) {
75
- hashes . push ( deployment . sha ) ;
75
+ hashes . push ( deployment . payload . version ) ;
76
76
envFound [ index ] = true ;
77
77
}
78
78
if ( ! -- pending && cb ) {
@@ -128,16 +128,12 @@ function maybeDeleteDroplet(providerTag, name, birthDate, del) {
128
128
// Why: every build produces an image
129
129
let maybeDeleteImage = ( function ( ) {
130
130
const pending = [ ] ;
131
- getDeployedHashes ( [ 'production' ] , ( err , hashes ) => {
131
+ getDeployedVersions ( [ 'production' ] , ( err , versions ) => {
132
132
if ( err ) fatal ( 'get deployed hashes:' , err ) ;
133
133
function isOrphanedImage ( name ) {
134
134
if ( ! name . startsWith ( 'image-' ) )
135
135
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 ) ) ;
141
137
}
142
138
maybeDeleteImage = function ( providerTag , name , birthDate , del ) {
143
139
if ( isOrphanedImage ( name ) && ageInHours ( birthDate ) > .5 ) {
0 commit comments