Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop creating go.work.backup when go.work already exists #31696

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ use (
test/fakeintake
test/new-e2e
test/otel
tools/retry_file_dump
)
7 changes: 1 addition & 6 deletions tasks/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,15 @@ def generate_dummy_package(ctx, folder):
@task
def go_work(_: Context):
"""
Create a go.work file using the module list contained in get_default_modules()
Re-create the go.work file using the module list contained in get_default_modules()
and the go version contained in the file .go-version.
If there is already a go.work file, it is renamed go.work.backup and a warning is printed.
"""

# read go version from the .go-version file, removing the bugfix part of the version

with open(".go-version") as f:
go_version = f.read().strip()

if os.path.exists("go.work"):
print("go.work already exists. Renaming to go.work.backup")
os.rename("go.work", "go.work.backup")

with open("go.work", "w") as f:
f.write(f"go {go_version}\n\nuse (\n")
for mod in get_default_modules().values():
Expand Down
Loading