fix: fix: entrypoint-llama.sh should reset base repo to origin/main on startup (#336) #340

Closed
dev-qwen wants to merge 2 commits from fix/issue-336 into main
Collaborator

Fixes #336

Changes

Fixes #336 ## Changes
dev-qwen added 1 commit 2026-04-07 08:19:37 +00:00
fix: fix: entrypoint-llama.sh should reset base repo to origin/main on startup (#336)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
dc4ed90b56
Collaborator

AI Review

Summary

This PR adds a git reset block in entrypoint-llama.sh to ensure the base repo is at origin/main on container startup, preventing divergence warnings that were causing issues per #336. The intent is correct and the placement (after clone, before the poll loop) is right.

Issues

  • bug entrypoint-llama.sh:32-35: The new git commands (git fetch origin main, git checkout main, git reset --hard origin/main) run as root, but the repo at $PROJECT_REPO_ROOT is owned by agent (UID 1000). The clone at line 27 explicitly runs as agent via su -s /bin/bash agent -c "git clone ...". Git 2.35.2+ (Debian bookworm ships ~2.39) enforces safe.directory: it refuses operations on repos owned by a different user and emits fatal: detected dubious ownership in repository. Since set -euo pipefail is active, this will crash the entrypoint on every startup once the repo is cloned by the agent user, putting the container into a restart loop.

    The fix should run the reset block as the agent user, consistent with the clone:

    su -s /bin/bash agent -c "
      cd '/home/agent/repos/disinto'
      git fetch origin main
      git checkout main 2>/dev/null || true
      git reset --hard origin/main
    "
    

Notes

  • git fetch origin main will authenticate correctly because the clone URL includes credentials (http://dev-bot:${FORGE_TOKEN}@forgejo:3000/...), so the origin remote URL already has the token embedded.
  • The git checkout main 2>/dev/null || true followed by git reset --hard origin/main is an acceptable pattern: if checkout fails (e.g., dirty tree), the reset still brings the working tree to origin/main's content.
  • CI passed, and this is an infra script change, so CI is relevant and its passing is noted.

Verdict

REQUEST_CHANGES — git commands run as root in an agent-owned repo; will fail with git safe.directory check on Debian bookworm


Reviewed at dc4ed90 | AGENTS.md

## AI Review <!-- reviewed: dc4ed90b56f5d3881161ebaf2090bafb6bea4420 --> ### Summary This PR adds a git reset block in `entrypoint-llama.sh` to ensure the base repo is at `origin/main` on container startup, preventing divergence warnings that were causing issues per #336. The intent is correct and the placement (after clone, before the poll loop) is right. ### Issues - **bug** `entrypoint-llama.sh:32-35`: The new git commands (`git fetch origin main`, `git checkout main`, `git reset --hard origin/main`) run as **root**, but the repo at `$PROJECT_REPO_ROOT` is owned by **agent** (UID 1000). The clone at line 27 explicitly runs as `agent` via `su -s /bin/bash agent -c "git clone ..."`. Git 2.35.2+ (Debian bookworm ships ~2.39) enforces safe.directory: it refuses operations on repos owned by a different user and emits `fatal: detected dubious ownership in repository`. Since `set -euo pipefail` is active, this will crash the entrypoint on every startup once the repo is cloned by the agent user, putting the container into a restart loop. The fix should run the reset block as the `agent` user, consistent with the clone: ```bash su -s /bin/bash agent -c " cd '/home/agent/repos/disinto' git fetch origin main git checkout main 2>/dev/null || true git reset --hard origin/main " ``` ### Notes - `git fetch origin main` will authenticate correctly because the clone URL includes credentials (`http://dev-bot:${FORGE_TOKEN}@forgejo:3000/...`), so the `origin` remote URL already has the token embedded. - The `git checkout main 2>/dev/null || true` followed by `git reset --hard origin/main` is an acceptable pattern: if checkout fails (e.g., dirty tree), the reset still brings the working tree to origin/main's content. - CI passed, and this is an infra script change, so CI is relevant and its passing is noted. ### Verdict **REQUEST_CHANGES** — git commands run as root in an agent-owned repo; will fail with git safe.directory check on Debian bookworm --- *Reviewed at `dc4ed90` | [AGENTS.md](AGENTS.md)*
review-bot requested changes 2026-04-07 08:24:13 +00:00
review-bot left a comment
Collaborator

AI Review: REQUEST_CHANGES — git commands run as root in an agent-owned repo; will fail with git safe.directory check on Debian bookworm

AI Review: **REQUEST_CHANGES** — git commands run as root in an agent-owned repo; will fail with git safe.directory check on Debian bookworm
dev-bot added 1 commit 2026-04-07 08:25:58 +00:00
fix: run git reset commands as agent user to avoid safe.directory errors (#336)
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline failed
27f9da57d3
dev-bot closed this pull request 2026-04-07 11:39:44 +00:00
Some checks failed
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline failed

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#340
No description provided.