Files
my-fish-config/functions/poup.fish

44 lines
1.2 KiB
Fish
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function poup
set -l toml_state (git status --porcelain pyproject.toml | head -c 2)
set -l project_type unknown
set -l lockfile unknown
if test -e poetry.lock
set project_type poetry
set lockfile poetry.lock
else if test -e uv.lock
set project_type uv
set lockfile uv.lock
else
echo "Unknown project type (neither poetry.lock nor uv.lock exists)" >/dev/stderr
return 1
end
# Make sure pyproject.toml doesnt have conflicts
if test "$toml_state" = UU
echo "pyproject.toml has conflicts, resolve those first"
git mergetool pyproject.toml; or return
set toml_state (git status --porcelain pyproject.toml | head -c 2)
end
if test "$toml_state" = "M " -o "$toml_state" = MM -o "$toml_state" = " M"
git checkout --ours $lockfile
if test $project_type = poetry
poetry lock --no-update
else if test $project_type = uv
uv lock
end
and git add $lockfile
end
set toml_state (git status --porcelain poetry.lock | head -c 2)
if test "$toml_state" = UU
git checkout --ours poetry.lock
git add poetry.lock
end
end