From 5b6feba582189f02b7d33dafa2d0c708d7234782 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Tue, 1 Oct 2024 16:01:33 -0500 Subject: [PATCH] incorporate code review feedback: nesting depth Signed-off-by: Matt Benson --- .../src/actions/gitlabMergeRequest.ts | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts index 616fdc1fd2..58c461c5fa 100644 --- a/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts +++ b/plugins/scaffolder-backend-module-gitlab/src/actions/gitlabMergeRequest.ts @@ -51,24 +51,23 @@ async function getFileAction( ): Promise<'create' | 'delete' | 'update' | 'skip'> { if (defaultCommitAction === 'auto') { const filePath = path.join(fileInfo.targetPath ?? '', fileInfo.file.path); - if (remoteFiles) { - if (remoteFiles.some(remoteFile => remoteFile.path === filePath)) { - try { - const targetFile = await api.RepositoryFiles.show( - target.repoID, - filePath, - target.branch, - ); - if (computeSha256(fileInfo.file) === targetFile.content_sha256) { - return 'skip'; - } - } catch (error) { - ctx.logger.warn( - `Unable to retrieve detailed information for remote file ${filePath}`, - ); + + if (remoteFiles?.some(remoteFile => remoteFile.path === filePath)) { + try { + const targetFile = await api.RepositoryFiles.show( + target.repoID, + filePath, + target.branch, + ); + if (computeSha256(fileInfo.file) === targetFile.content_sha256) { + return 'skip'; } - return 'update'; + } catch (error) { + ctx.logger.warn( + `Unable to retrieve detailed information for remote file ${filePath}`, + ); } + return 'update'; } return 'create'; }