@@ -328,22 +328,34 @@ function getGitMetadata (ciMetadata) {
328328 committerDate
329329 ] = sanitizedExec ( 'git' , [ 'show' , '-s' , '--format=%an,%ae,%aI,%cn,%ce,%cI' ] ) . split ( ',' )
330330
331- return {
332- [ GIT_REPOSITORY_URL ] :
333- filterSensitiveInfoFromRepository ( repositoryUrl || sanitizedExec ( 'git' , [ 'ls-remote' , '--get-url' ] ) ) ,
331+ const tags = {
334332 [ GIT_COMMIT_MESSAGE ] :
335333 commitMessage || sanitizedExec ( 'git' , [ 'show' , '-s' , '--format=%s' ] ) ,
336- [ GIT_COMMIT_AUTHOR_DATE ] : authorDate ,
337- [ GIT_COMMIT_AUTHOR_NAME ] : ciAuthorName || authorName ,
338- [ GIT_COMMIT_AUTHOR_EMAIL ] : ciAuthorEmail || authorEmail ,
339- [ GIT_COMMIT_COMMITTER_DATE ] : committerDate ,
340- [ GIT_COMMIT_COMMITTER_NAME ] : committerName ,
341- [ GIT_COMMIT_COMMITTER_EMAIL ] : committerEmail ,
342334 [ GIT_BRANCH ] : branch || sanitizedExec ( 'git' , [ 'rev-parse' , '--abbrev-ref' , 'HEAD' ] ) ,
343335 [ GIT_COMMIT_SHA ] : commitSHA || sanitizedExec ( 'git' , [ 'rev-parse' , 'HEAD' ] ) ,
344- [ GIT_TAG ] : tag ,
345336 [ CI_WORKSPACE_PATH ] : ciWorkspacePath || sanitizedExec ( 'git' , [ 'rev-parse' , '--show-toplevel' ] )
346337 }
338+
339+ const entries = [
340+ GIT_REPOSITORY_URL ,
341+ filterSensitiveInfoFromRepository ( repositoryUrl || sanitizedExec ( 'git' , [ 'ls-remote' , '--get-url' ] ) ) ,
342+ GIT_COMMIT_AUTHOR_DATE , authorDate ,
343+ GIT_COMMIT_AUTHOR_NAME , ciAuthorName || authorName ,
344+ GIT_COMMIT_AUTHOR_EMAIL , ciAuthorEmail || authorEmail ,
345+ GIT_COMMIT_COMMITTER_DATE , committerDate ,
346+ GIT_COMMIT_COMMITTER_NAME , committerName ,
347+ GIT_COMMIT_COMMITTER_EMAIL , committerEmail ,
348+ GIT_TAG , tag
349+ ]
350+
351+ for ( let i = 0 ; i < entries . length ; i += 2 ) {
352+ const value = entries [ i + 1 ]
353+ if ( value ) {
354+ tags [ entries [ i ] ] = value
355+ }
356+ }
357+
358+ return tags
347359}
348360
349361module . exports = {
0 commit comments