Skip to content

Commit

Permalink
add go mod tidy command execution after commit hash substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
btc-fan committed Aug 7, 2024
1 parent 03d7bbf commit 341bf45
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion scripts/update-go-mod/update-go-mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def update_go_mod_file(go_mod_path, new_hash):
"""
Update the go.mod file with the new commit hash.
Update the go.mod file with the new commit hash.
"""
try:
with open(go_mod_path, 'r') as file:
Expand All @@ -27,6 +27,19 @@ def update_go_mod_file(go_mod_path, new_hash):
print(f"Failed to update go.mod file: {str(e)}")
sys.exit(1)

def run_go_mod_tidy():
"""
Run `go mod tidy` to ensure the go.mod file is tidy.
"""
try:
print("Running go mod tidy...")
subprocess.run(['go', 'mod', 'tidy'], check=True)
print("Successfully ran go mod tidy.")

except subprocess.CalledProcessError as e:
print(f"Failed to run go mod tidy: {e.stderr}")
sys.exit(1)

if __name__ == "__main__":
try:
# Assuming the script is run from the root of mx-chain-simulator-go
Expand All @@ -43,6 +56,9 @@ def update_go_mod_file(go_mod_path, new_hash):

update_go_mod_file(go_mod_path, latest_commit_hash)

# Run go mod tidy after updating go.mod
run_go_mod_tidy()

print("Python Script executed successfully.")
except Exception as e:
print(f"Script execution failed: {str(e)}")
Expand Down

0 comments on commit 341bf45

Please sign in to comment.