Skip to content

Commit a68a9f8

Browse files
committed
Add bin/git-resolve-poetry-lock.sh to resolve merge conficts
Previously I was just doing poetry update to resolve such conflicts, but that's not really ideal because it updates all libs. poetry lock --no-update is better, but even better to base the changes from their version of poetry-lock and then add only my changes as required by pyproject.yaml. You can use this script if you get a merge conflict with poetry.lock and it will just do the right thing. btw: in my powermon/structuredlogging branch I have a commit to add support for the "poe" tool which will provide a shortcut for this script.
1 parent 18c2d08 commit a68a9f8

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

bin/git-resolve-poetry-lock.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# This is a little helper you can use to resolve git merge conflicts in poetry.lock
6+
# with minimal changes vs the requested lib versions
7+
# Based on this article with a good description of best practices:
8+
# https://www.peterbe.com/plog/how-to-resolve-a-git-conflict-in-poetry.lock
9+
10+
echo "Resolving poetry.lock merge conflicts, you'll need to run git commit yourself..."
11+
12+
# Get poetry.lock to look like it does in master
13+
git checkout --theirs poetry.lock
14+
# Rewrite the lock file
15+
poetry lock --no-update
16+
git add poetry.lock
17+
18+
# Update your poetry env to match the new merged lock file
19+
poetry install

0 commit comments

Comments
 (0)