Skip to content
Open
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,23 @@ cd ~/.ai-workflows && git pull
aiw-update
```

If your upstream remote is not named `origin` (for example `redhat/main`), set
`AI_WORKFLOWS_REMOTE_REF` so `aiw-update` and the daily update check use the
same ref:

```bash
export AI_WORKFLOWS_REMOTE_REF=redhat/main
aiw-update
```

For the systemd timer, add a drop-in under
`~/.config/systemd/user/ai-workflows-update-check.service.d/` with
`Environment=AI_WORKFLOWS_REMOTE_REF=redhat/main`, then
`systemctl --user daemon-reload`.

### Optional: daily update notifier (Linux)

On Linux desktops with systemd user sessions and `notify-send`, `install.sh` can prompt to enable a daily check. If `~/.ai-workflows` is behind `origin/main`, you get a desktop notification suggesting `aiw-update`.
On Linux desktops with systemd user sessions and `notify-send`, `install.sh` can prompt to enable a daily check. If `~/.ai-workflows` is behind the configured upstream ref (default `origin/main`), you get a desktop notification suggesting `aiw-update`.

```bash
./install.sh cursor # prompts [y/N] when supported
Expand Down
21 changes: 15 additions & 6 deletions hack/aiw-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Pull latest ai-workflows and refresh installs if command wrappers changed.
#
# Usage:
# aiw-update # ff-only pull origin/main (must be on main)
# aiw-update # ff-only pull AI_WORKFLOWS_REMOTE_REF (default origin/main)
# aiw-update --checkout-main # checkout main first, then pull
# aiw-update --reinstall # always re-run install.sh for detected targets
# aiw-update --project PATH # also reinstall Cursor skills for PATH (repeatable)
Expand All @@ -12,6 +12,7 @@
set -euo pipefail

INSTALL_DIR="${AI_WORKFLOWS_DIR:-${HOME}/.ai-workflows}"
REMOTE_REF="${AI_WORKFLOWS_REMOTE_REF:-origin/main}"
REPO_DIR="$(readlink -f "$INSTALL_DIR")"
CHECKOUT_MAIN=false
FORCE_REINSTALL=false
Expand Down Expand Up @@ -92,7 +93,7 @@ CURRENT_BRANCH="$(git branch --show-current 2>/dev/null || true)"
if [[ "$CURRENT_BRANCH" != "main" ]] && ! $CHECKOUT_MAIN; then
echo "ai-workflows: not on main (branch=${CURRENT_BRANCH:-detached})." >&2
echo " Use: aiw-update --checkout-main" >&2
echo " Or rebase/merge origin/main into this branch, then retry." >&2
echo " Or rebase/merge ${REMOTE_REF} into this branch, then retry." >&2
exit 1
fi

Expand All @@ -102,10 +103,18 @@ if $CHECKOUT_MAIN; then
git checkout main
fi

git fetch origin main
if ! git pull --ff-only origin main; then
echo "ai-workflows: fast-forward pull from origin/main failed." >&2
echo " Resolve local commits on main, or: git reset --hard origin/main (destructive)." >&2
FETCH_REMOTE="${REMOTE_REF%%/*}"
FETCH_BRANCH="${REMOTE_REF#*/}"
if [[ "$FETCH_REMOTE" == "$REMOTE_REF" ]]; then
FETCH_REMOTE="origin"
FETCH_BRANCH="$REMOTE_REF"
fi
MERGE_REF="refs/remotes/${FETCH_REMOTE}/${FETCH_BRANCH}"

git fetch "$FETCH_REMOTE" "$FETCH_BRANCH"
if ! git merge --ff-only "$MERGE_REF"; then
echo "ai-workflows: fast-forward pull from ${REMOTE_REF} failed." >&2
echo " Resolve local commits on main, or: git reset --hard ${MERGE_REF} (destructive)." >&2
exit 1
fi

Expand Down
9 changes: 5 additions & 4 deletions hack/update-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ if [[ "$FETCH_REMOTE" == "$REMOTE_REF" ]]; then
FETCH_REMOTE="origin"
FETCH_BRANCH="$REMOTE_REF"
fi
MERGE_REF="refs/remotes/${FETCH_REMOTE}/${FETCH_BRANCH}"

# Fetch quietly; network failures should not spam the user.
if ! git fetch --quiet "$FETCH_REMOTE" "$FETCH_BRANCH" 2>/dev/null; then
echo "ai-workflows: fetch failed (offline?); skipping check"
exit 0
fi

if ! git rev-parse --verify "$REMOTE_REF" >/dev/null 2>&1; then
echo "ai-workflows: missing ref $REMOTE_REF" >&2
if ! git rev-parse --verify "$MERGE_REF" >/dev/null 2>&1; then
echo "ai-workflows: missing ref $MERGE_REF" >&2
exit 0
fi

REMOTE_SHA="$(git rev-parse "$REMOTE_REF")"
BEHIND="$(git rev-list --count "HEAD..${REMOTE_REF}" 2>/dev/null || echo 0)"
REMOTE_SHA="$(git rev-parse "$MERGE_REF")"
BEHIND="$(git rev-list --count "HEAD..${MERGE_REF}" 2>/dev/null || echo 0)"
BRANCH="$(git branch --show-current 2>/dev/null || echo detached)"
UPDATE_CMD="aiw-update"
if [[ "$BRANCH" != "main" ]]; then
Expand Down
Loading