Skip to content

Commit

Permalink
tea handles pantry updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Oct 24, 2022
1 parent b774e23 commit a2b076f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[`install.sh`](./install.sh) is delivered when you `curl tea.xyz`.

# GitHub Action 0.6.2
# GitHub Action 0.6.3

This repository also provides the `tea` GitHub Action.

Expand Down
39 changes: 4 additions & 35 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -215,37 +215,6 @@ function install {
echo #spacer
}

function update_pantry {
mkdir -p "$TEA_PREFIX/tea.xyz/tmp"
sh="$TEA_PREFIX/tea.xyz/tmp/update-pantry.sh"

cat <<-EOSH >"$sh"
set -e
cd "$TEA_PREFIX"/tea.xyz/var/pantry
if test -n "$VERBOSE"; then
set -x
fi
test -z "\$(git status --porcelain)" || return 0
if ! git diff --quiet; then return 0; fi
test "\$(git branch --show-current)" = main || return 0
git remote update
BASE="\$(git merge-base @ '@{u}')"
LOCAL="\$(git rev-parse @)"
if test "\$BASE" = "\$LOCAL"; then
git pull
fi
EOSH

if ! gum spin --title "updating pantry" -- bash "$sh"; then
gum format -- "> failed to update pantry"
fi
}

function check_path {
gum format -- <<-EOMD
# one second!
Expand Down Expand Up @@ -320,12 +289,12 @@ fi

case $MODE in
install)
if ! test -d "$TEA_PREFIX/tea.xyz/var/pantry/.git"; then
#FIXME || true because tea/cli doesn’t like zero args currently will fix tho
gum spin --title "prefetching pantry" -- $tea -S
if ! test -d "$TEA_PREFIX/tea.xyz/var/pantry"; then
title="prefetching"
elif which git >/dev/null 2>&1; then
update_pantry
title="syncing"
fi
gum spin --title "$title pantry" -- "$tea" --sync

if ! (("$ALREADY_INSTALLED")); then
check_path
Expand Down

0 comments on commit a2b076f

Please sign in to comment.