Skip to content

go-mod-tidy-repo should have an argument for excludes #37

Open
@balihb

Description

@balihb

we have a repository with multiple modules depending on each other. the problem is that in the CI we are storing some tool's go dependencies inside the repo dir with asdf ( https://github.com/asdf-community/asdf-golang?tab=readme-ov-file#when-using-go-get-or-go-install ) under the .cache directory, so the CI can save it and go-mod-tidy-repo will try to run on them too. I've tried with hard-coding an exclusion for .cache and it worked.

diff --git a/lib/cmd-repo-mod.bash b/lib/cmd-repo-mod.bash
index c44b9d50a51e5ab7a0362d6544bf9b45f30df9d1..163a9449394a73ade50cd0b7c4d84df9e4e44753 100644
--- a/lib/cmd-repo-mod.bash
+++ b/lib/cmd-repo-mod.bash
@@ -12,7 +12,7 @@ export GO111MODULE=on
 error_code=0
 # Assume parent folder of go.mod is module root folder
 #
-for sub in $(find . -name go.mod -not -path '*/vendor/*' -exec dirname "{}" ';' | sort -u); do
+for sub in $(find . -name go.mod -not -path '*/vendor/*' -not -path '*/.cache/*' -exec dirname "{}" ';' | sort -u); do
 	pushd "${sub}" > /dev/null || exit 1
 	if [ "${error_on_output:-}" -eq 1 ]; then
 		output=$(/usr/bin/env "${ENV_VARS[@]}" "${cmd[@]}" "${OPTIONS[@]}" 2>&1)

obviously it won't scale for other similar use cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions