Skip to content

Commit

Permalink
fix: run validation with --no-deps when pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
renatav committed Jan 7, 2025
1 parent 4b46e8a commit dbb6c85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
4 changes: 1 addition & 3 deletions taf/resources/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
# Path to the TAF CLI executable
TAF_CLI="taf"

# Get the last validated commit using the new CLI command
output=$($TAF_CLI repo latest-commit-and-branch)

# Get the last validated commit using the new CLI command
if [ $? -ne 0 ]; then
echo "Failed to retrieve the last validated commit."
DEFAULT_BRANCH=""
Expand Down Expand Up @@ -34,7 +32,7 @@ fi


# Run the TAF validation command with --from-latest
$TAF_CLI repo validate --from-latest
$TAF_CLI repo validate --from-latest --no-deps
VALIDATION_STATUS=$?

# Check the validation status
Expand Down
42 changes: 19 additions & 23 deletions taf/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import platform
import re
import click
import errno
import datetime
Expand Down Expand Up @@ -394,30 +395,25 @@ def ensure_pre_push_hook(auth_repo_path: Path) -> bool:
Path(__file__).parent / "resources" / "pre-push"
).resolve()

if not pre_push_script.exists():
if not resources_pre_push_script.exists():
taf_logger.error(
f"Resources pre-push script not found at {resources_pre_push_script}"
)
return False
# always copy the newest version of the pre-push hook

shutil.copy(resources_pre_push_script, pre_push_script)
try:
if platform.system() != "Windows":
# Unix-like systems
pre_push_script.chmod(0o755)
except Exception as e:
taf_logger.error(f"Error setting executable permission: {e}")
return False

# Check if permissions were set correctly on Unix-like systems
if platform.system() != "Windows" and not os.access(pre_push_script, os.X_OK):
taf_logger.error(
f"Failed to set pre-push git hook executable permission. Please set it manually for {pre_push_script}."
)
return False
taf_logger.info("Pre-push hook not present. Pre-push hook added successfully.")
return True
shutil.copy(resources_pre_push_script, pre_push_script)
try:
if platform.system() != "Windows":
# Unix-like systems
pre_push_script.chmod(0o755)
except Exception as e:
taf_logger.error(f"Error setting executable permission: {e}")
return False

# Check if permissions were set correctly on Unix-like systems
if platform.system() != "Windows" and not os.access(pre_push_script, os.X_OK):
taf_logger.error(
f"Failed to set pre-push git hook executable permission. Please set it manually for {pre_push_script}."
)
return False
taf_logger.info("Pre-push hook not present. Pre-push hook added successfully.")
return True

return True

Expand Down

0 comments on commit dbb6c85

Please sign in to comment.