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

remove original build files before running gazelle #1536

Closed
Closed
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
7 changes: 7 additions & 0 deletions internal/go_repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ def _go_repository_impl(ctx):
generate = generate or (not existing_build_file and ctx.attr.build_file_generation == "auto")

if generate:
# Remove the original build files
workspace_path = str(ctx.path(""))
cmd_rm = "rm -rf {}/WORKSPACE `find {} -name 'BUILD.bazel'` {}.bazel* `find {} -name 'BUILD'`".format(workspace_path, workspace_path, workspace_path, workspace_path)
result = ctx.execute(["/bin/bash", "-c", cmd_rm])
if result.return_code != 0:
fail("Failed to execute command: " + result.stderr)

# Build file generation is needed. Populate Gazelle directive at root build file
build_file_name = existing_build_file or build_file_names[0]
if len(ctx.attr.build_directives) > 0:
Expand Down