diff --git a/lib/manager/gomod/artifacts.js b/lib/manager/gomod/artifacts.js index b5d3d05f7babbdac56bf733fb515bee9b94a5fa8..cfdbe02b2a1cd8b9dfc0c20a1d2f83f3336dcb50 100644 --- a/lib/manager/gomod/artifacts.js +++ b/lib/manager/gomod/artifacts.js @@ -114,8 +114,8 @@ async function getArtifacts( duration = process.hrtime(startTime); seconds = Math.round(duration[0] + duration[1] / 1e9); logger.info( - { seconds, type: 'go.sum', stdout, stderr }, - 'Tidied lockfile' + { seconds, stdout, stderr }, + 'Tidied Go Modules after update' ); } else { logger.warn( @@ -163,6 +163,27 @@ async function getArtifacts( duration = process.hrtime(startTime); seconds = Math.round(duration[0] + duration[1] / 1e9); logger.info({ seconds, stdout, stderr }, 'Vendored modules'); + if ( + config.postUpdateOptions && + config.postUpdateOptions.includes('gomodTidy') + ) { + args = 'mod tidy'; + if (cmd.includes('.insteadOf')) { + args += '"'; + } + logger.debug({ cmd, args }, 'go mod tidy command'); + ({ stdout, stderr } = await exec(`${cmd} ${args}`, { + cwd, + shell: true, + env, + })); + duration = process.hrtime(startTime); + seconds = Math.round(duration[0] + duration[1] / 1e9); + logger.info( + { seconds, stdout, stderr }, + 'Tidied Go Modules after vendoring' + ); + } const status = await platform.getRepoStatus(); for (const f of status.modified.concat(status.not_added)) { if (f.startsWith(vendorDir)) {