Skip to content
Snippets Groups Projects
Commit 8f79b660 authored by Paul Tyng's avatar Paul Tyng Committed by Rhys Arkins
Browse files

feat(gomod): Run `go mod tidy` if configured (#3201)

Adds a configurable option to run `go mod tidy` on a repo between the `go get...` and the `go mod vendor`.

Closes #2594
parent d35b6733
No related branches found
No related tags found
No related merge requests found
...@@ -1064,6 +1064,12 @@ const options = [ ...@@ -1064,6 +1064,12 @@ const options = [
}, },
mergeable: true, mergeable: true,
}, },
{
name: 'gomodTidy',
description: 'Enable to run `go mod tidy` after Go module updates',
type: 'boolean',
default: false,
},
{ {
name: 'ruby', name: 'ruby',
releaseStatus: 'alpha', releaseStatus: 'alpha',
......
...@@ -78,6 +78,28 @@ async function getArtifacts( ...@@ -78,6 +78,28 @@ async function getArtifacts(
{ seconds, type: 'go.sum', stdout, stderr }, { seconds, type: 'go.sum', stdout, stderr },
'Generated lockfile' 'Generated lockfile'
); );
// istanbul ignore if
if (config.gomodTidy) {
if (config.gitFs) {
args = 'mod tidy';
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, type: 'go.sum', stdout, stderr },
'Tidied lockfile'
);
} else {
logger.warn(
'Renovate administrator should enable gitFs in order to support tidying go modules'
);
}
}
const res = []; const res = [];
// istanbul ignore if // istanbul ignore if
if (config.gitFs) { if (config.gitFs) {
......
...@@ -27,6 +27,7 @@ Array [ ...@@ -27,6 +27,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -124,6 +125,7 @@ Array [ ...@@ -124,6 +125,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -219,6 +221,7 @@ Array [ ...@@ -219,6 +221,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -318,6 +321,7 @@ Array [ ...@@ -318,6 +321,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -413,6 +417,7 @@ Array [ ...@@ -413,6 +417,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -512,6 +517,7 @@ Array [ ...@@ -512,6 +517,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}}", "commitMessageTopic": "{{{groupName}}}",
...@@ -609,6 +615,7 @@ Array [ ...@@ -609,6 +615,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}} Docker tags", "commitMessageTopic": "{{{groupName}}} Docker tags",
...@@ -706,6 +713,7 @@ Array [ ...@@ -706,6 +713,7 @@ Array [
"gitAuthor": null, "gitAuthor": null,
"gitFs": null, "gitFs": null,
"gitPrivateKey": null, "gitPrivateKey": null,
"gomodTidy": false,
"group": Object { "group": Object {
"branchTopic": "{{{groupSlug}}}", "branchTopic": "{{{groupSlug}}}",
"commitMessageTopic": "{{{groupName}}} Docker tags", "commitMessageTopic": "{{{groupName}}} Docker tags",
......
...@@ -247,6 +247,8 @@ Configuration added here applies for all Go-related updates, however currently t ...@@ -247,6 +247,8 @@ Configuration added here applies for all Go-related updates, however currently t
Configuration for Go Modules (`go mod`). Supersedes anything in the `go` config object. Configuration for Go Modules (`go mod`). Supersedes anything in the `go` config object.
## gomodTidy
## gradle ## gradle
Configuration for Java gradle projects Configuration for Java gradle projects
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment