Skip to content

Commit

Permalink
kp_common: fix worktree mount logic
Browse files Browse the repository at this point in the history
I know right now docker ignores "-v : " but I do not want to see what
happens if this ever changes. Besides, we can't do anything if we're not
working in a git directory anyway.

Signed-off-by: Randolph Sapp <[email protected]>
  • Loading branch information
StaticRocket committed Mar 10, 2024
1 parent f9dfddd commit 2ea360f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kp_common
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,13 @@ DOCKER_MOUNT_DIRS+=(-v /opt:/opt)
DOCKER_MOUNT_DIRS+=(-v "$CCACHEDIR":/ccache)
DOCKER_MOUNT_DIRS+=(-v "$(pwd)":/workdir)

# Check if current directory is a git directory
if ! GIT_WORKTREE_COMMONDIR=$(git rev-parse --git-common-dir); then
exit 1
fi

# Mount parent directory if its a worktree
GIT_WORKTREE_COMMONDIR=$(git rev-parse --git-common-dir)
if [[ $GIT_WORKTREE_COMMONDIR != ".git" ]]; then
if [ "$GIT_WORKTREE_COMMONDIR" != ".git" ]; then
DOCKER_MOUNT_DIRS+=(-v "$GIT_WORKTREE_COMMONDIR":"$GIT_WORKTREE_COMMONDIR")
fi

Expand Down

0 comments on commit 2ea360f

Please sign in to comment.