Skip to content
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
137 changes: 0 additions & 137 deletions Plans/release-first-pipeline-2026-03-27.md

This file was deleted.

10 changes: 10 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ INSTALL_DIR="${HOME}/.local/bin"
SCRIPT_REAL=$(readlink "$0" 2>/dev/null || echo "$0")
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_REAL")" && pwd)"

# Release guard: prevent accidental installs from development state
TAG=$(git -C "$SCRIPT_DIR" describe --exact-match HEAD 2>/dev/null || true)
if [ -z "$TAG" ] && [ "$1" != "--dev" ]; then
echo "WARNING: Not a tagged release commit ($(git -C "$SCRIPT_DIR" rev-parse --short HEAD 2>/dev/null || echo 'unknown'))." >&2
echo "Use './install.sh --dev' to install from development state." >&2
echo "For production installs, download from: https://github.com/DAESA24/op-env/releases" >&2
exit 1
fi
if [ "${1:-}" = "--dev" ]; then shift; fi

VERSION=$(cat "$SCRIPT_DIR/version.txt" 2>/dev/null || echo "dev")

mkdir -p "$INSTALL_DIR"
Expand Down
29 changes: 27 additions & 2 deletions test/test-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ run_install() {
HOME_BACKUP="$HOME"
# Override HOME so install.sh writes to our temp dir
export HOME="$install_dir"
(cd "$REPO_DIR" && bash install.sh 2>&1)
(cd "$REPO_DIR" && bash install.sh --dev 2>&1)
local rc=$?
export HOME="$HOME_BACKUP"
return $rc
Expand Down Expand Up @@ -121,7 +121,7 @@ rm -rf "$TMPDIR7"
TMPDIR8=$(mktemp -d)
HOME_BACKUP="$HOME"
export HOME="$TMPDIR8"
(cd /tmp && bash "$INSTALLER" 2>&1) > /dev/null
(cd /tmp && bash "$INSTALLER" --dev 2>&1) > /dev/null
rc=$?
export HOME="$HOME_BACKUP"
result="fail"
Expand Down Expand Up @@ -184,5 +184,30 @@ echo "$last_line" | grep -q 'exec "\$@"' && result="yes"
assert_eq "yes" "$result" "installed binary ends with exec (TTY preserved)"
rm -rf "$TMPDIR13"

# ============================================================
# Category 5: Guard Tests — Release Tag Check
# ============================================================

echo "--- Guard: Release tag check ---"

# Test 14: install.sh rejects untagged commit without --dev
TMPDIR14=$(mktemp -d)
HOME_BACKUP="$HOME"
export HOME="$TMPDIR14"
output=$(cd "$REPO_DIR" && bash install.sh 2>&1)
rc=$?
export HOME="$HOME_BACKUP"
assert_eq "1" "$rc" "guard rejects untagged commit without --dev"
assert_contains "$output" "WARNING" "guard prints WARNING on rejection"
rm -rf "$TMPDIR14"

# Test 15: install.sh accepts --dev flag on untagged commit
TMPDIR15=$(mktemp -d)
run_install "$TMPDIR15" > /dev/null
result="missing"
[ -f "$TMPDIR15/.local/bin/op-env" ] && result="installed"
assert_eq "installed" "$result" "guard accepts --dev flag on untagged commit"
rm -rf "$TMPDIR15"

# ============================================================
report
Loading