Skip to content

Commit

Permalink
Support Windows and maintain separate git index when running container
Browse files Browse the repository at this point in the history
  • Loading branch information
cl8n committed Dec 3, 2023
1 parent 821b9f5 commit fa082a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion meta/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -eu
set -eu -- meta/docker-msys-swap-git-index.sh "$@"

host_uid="$(stat -c %u /osu-wiki)"
host_gid="$(stat -c %g /osu-wiki)"
Expand Down
29 changes: 29 additions & 0 deletions meta/docker-msys-swap-git-index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

set -eu

if test -z "$OSU_WIKI_MSYS"; then
exec "$@"
fi

mv -T .git/index .git/index-host

if test -f .git/index-container; then
mv -T .git/index-container .git/index
else
printf '\033[1m## This is your first time running the Docker container.\n' >&2
printf '## A separate git index needs to be maintained when using this container on Windows.\n' >&2
printf '## Please \033[4mDO NOT\033[0;1m run any git commands while this container is running.\n' >&2
printf '## Creating index... (this may take a while)\033[m\n' >&2
git reset >/dev/null 2>&1
printf '\033[1;32m## Created index. It will be stored at \033[4m.git/index-container\033[0;1;32m.\033[m\n' >&2
fi

"$@" && :

exit_code=$?

mv -T .git/index .git/index-container
mv -T .git/index-host .git/index

exit "$exit_code"
4 changes: 3 additions & 1 deletion run-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ build_docker_image() {
}

run_in_docker() {
msys="$(test -z "${MSYSTEM:-}" || printf 1)"
remove_node_modules="$(test -e node_modules || printf 1)"

# Map the host repo directory to /osu-wiki, but use node_modules from the
# image. Don't exit the script on fail; store the exit code to return later
docker run \
MSYS_NO_PATHCONV="$msys" docker run \
-e "OSU_WIKI_MSYS=$msys" \
--rm \
--volume "$(pwd):/osu-wiki" \
--volume /osu-wiki/node_modules/ \
Expand Down

0 comments on commit fa082a9

Please sign in to comment.