This commit is contained in:
parent
0a6efbded9
commit
bc0d0ea889
@ -71,15 +71,20 @@ fi
|
||||
echo -e "\nTest 2: First run with directory argument"
|
||||
# Use a directory that should exist in most environments
|
||||
TEST_DIR="/tmp"
|
||||
echo " Testing with directory: $TEST_DIR"
|
||||
if [ -d "$TEST_DIR" ]; then
|
||||
"$WHATSDIRTY_SCRIPT" "$TEST_DIR" > /dev/null 2>&1
|
||||
if [ -f "$CONFIG_FILE" ] && [ "$(cat "$CONFIG_FILE")" = "$TEST_DIR" ]; then
|
||||
echo " Directory exists, running script..."
|
||||
SCRIPT_OUTPUT=$("$WHATSDIRTY_SCRIPT" "$TEST_DIR" 2>&1)
|
||||
SCRIPT_EXIT_CODE=$?
|
||||
echo " Script exit code: $SCRIPT_EXIT_CODE"
|
||||
if [ $SCRIPT_EXIT_CODE -eq 0 ] && [ -f "$CONFIG_FILE" ] && [ "$(cat "$CONFIG_FILE")" = "$TEST_DIR" ]; then
|
||||
print_test "Directory saved to config" "PASS"
|
||||
else
|
||||
print_test "Directory saved to config" "FAIL"
|
||||
echo " Expected config to contain: $TEST_DIR"
|
||||
echo " Config file exists: $([ -f "$CONFIG_FILE" ] && echo "yes" || echo "no")"
|
||||
[ -f "$CONFIG_FILE" ] && echo " Config contains: $(cat "$CONFIG_FILE")"
|
||||
echo " Script output: $SCRIPT_OUTPUT"
|
||||
fi
|
||||
else
|
||||
print_test "Directory saved to config" "SKIP (test directory not found)"
|
||||
|
@ -62,8 +62,8 @@ get_last_commit_hours() {
|
||||
local current_timestamp=$(date +%s)
|
||||
local diff_seconds=$((current_timestamp - last_commit_timestamp))
|
||||
|
||||
# Convert to hours with decimal precision
|
||||
local hours_ago=$(echo "scale=1; $diff_seconds / 3600" | bc)
|
||||
# Convert to hours with decimal precision using awk (more portable than bc)
|
||||
local hours_ago=$(awk "BEGIN {printf \"%.1f\", $diff_seconds / 3600}")
|
||||
|
||||
# Ensure leading zero for values less than 1
|
||||
if [[ $hours_ago =~ ^\. ]]; then
|
||||
|
Loading…
x
Reference in New Issue
Block a user