Skip to content
Merged
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
20 changes: 12 additions & 8 deletions load_tooltips.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash

set -euo pipefail

echo "=== GCZ — TOOLTIP PIPELINE EXECUTION ==="

cd /var/www/html/Runewager || exit 1
cd /var/www/html/Runewager

echo "[1] Pulling latest from origin main..."
git pull origin main || exit 1
git pull origin main

echo "[2] Ensuring data directory exists..."
mkdir -p /var/www/html/Runewager/data
Expand All @@ -22,16 +24,18 @@ grep -qxF "data/tooltips.json" .gitignore || echo "data/tooltips.json" >> .gitig
echo "[7] Staging .gitignore only..."
git add .gitignore

echo "[8] Committing..."
git commit -m "GCZ: ensure tooltips.json exists, ignore it, and run load_tooltips.sh"
if git diff --cached --quiet; then
echo "[8] No changes to commit; skipping git commit/push."
else
echo "[8] Committing..."
git commit -m "GCZ: ensure tooltips.json exists, ignore it, and run load_tooltips.sh"
Comment on lines +27 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The script claims to stage and commit only the ignore rule, but git commit without a path will include any other already-staged files in the repo, potentially causing unintended commits; restricting both the diff check and the commit to .gitignore ensures only the intended file is pushed. [logic error]

Severity Level: Major ⚠️
- ❌ Script can push unrelated staged changes to origin main.
- ⚠️ Bypasses usual code review protections for those staged changes.
Suggested change
if git diff --cached --quiet; then
echo "[8] No changes to commit; skipping git commit/push."
else
echo "[8] Committing..."
git commit -m "GCZ: ensure tooltips.json exists, ignore it, and run load_tooltips.sh"
if git diff --cached --quiet -- .gitignore; then
echo "[8] No changes to commit; skipping git commit/push."
else
echo "[8] Committing..."
git commit -m "GCZ: ensure tooltips.json exists, ignore it, and run load_tooltips.sh" .gitignore
Steps of Reproduction ✅
1. In `/var/www/html/Runewager` (path used at `load_tooltips.sh:7`), modify a tracked file
such as `index.js` and stage it manually with `git add index.js`, leaving it in the index.

2. From the same repository root, execute the operational script `./load_tooltips.sh`
(script content confirmed at `/workspace/Runewager/load_tooltips.sh:1-63`).

3. The script executes the block at `load_tooltips.sh:24-25`, printing `"[7] Staging
.gitignore only..."` and running `git add .gitignore`, which adds `.gitignore` alongside
the already-staged `index.js`.

4. The conditional at `load_tooltips.sh:27` calls `git diff --cached --quiet` without a
pathspec, which detects any staged changes (including `index.js`), so it enters the `else`
branch and runs `git commit -m ...` at `load_tooltips.sh:31`, committing both `.gitignore`
and the unrelated `index.js` changes.

5. Immediately after, the script pushes this commit to `origin main` via `git push origin
main` at `load_tooltips.sh:34`, causing unintended, unreviewed changes from `index.js` (or
any other pre-staged files) to be pushed along with the `.gitignore` update.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** load_tooltips.sh
**Line:** 27:31
**Comment:**
	*Logic Error: The script claims to stage and commit only the ignore rule, but `git commit` without a path will include any other already-staged files in the repo, potentially causing unintended commits; restricting both the diff check and the commit to `.gitignore` ensures only the intended file is pushed.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎


echo "[9] Pushing to origin main..."
git push origin main
echo "[9] Pushing to origin main..."
git push origin main
fi

echo "=== GCZ — DONE ==="

set -euo pipefail

OUT="/var/www/html/Runewager/data/tooltips.json"
mkdir -p "$(dirname "$OUT")"

Expand Down