-
Notifications
You must be signed in to change notification settings - Fork 9
5.3 compat #562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
5.3 compat #562
Changes from 10 commits
c0de05b
91c34ba
2751e10
dad5634
c80a381
52166f8
1354be4
bc95331
2aa3d9c
ff57b57
33c9d94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +5 −2 | README.rst | |
| +1 −0 | docker-compose.yml | |
| +2 −1 | recipe_conda_python.Dockerfile | |
| +6 −15 | recipe_gosu.Dockerfile | |
| +5 −16 | recipe_tini-musl.Dockerfile | |
| +5 −16 | recipe_tini.Dockerfile | |
| +97 −0 | verify_gpg.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,30 @@ function load_vsi_compat() | |
| local bash_major_version="${BASH_VERSINFO[0]}" | ||
| local bash_minor_version="${bash_major_version}${BASH_VERSINFO[1]}" | ||
|
|
||
|
|
||
| #** | ||
| # .. var:: bash_behavior_null_pushd | ||
| # | ||
| # In bash version 5.3 and older, pushd on an empty string now returns an error instead of true. Additionally it does not push the cwd onto the directory stack. | ||
| # | ||
| # :Value: * ``0`` ``pushd ""`` returns 0 | ||
| # * ``1`` ``pushd ""`` returns 1 | ||
| # | ||
| # .. var:: bash_behavior_multiline_caller | ||
| # | ||
| # In bash version 5.3 and older, caller returns the first line of a multiline command, whereas before it returned the last line. | ||
| # | ||
| # :Value: * ``0`` ``pushd ""`` returns 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this example right? I dont se a multi-line command |
||
| # * ``1`` ``pushd ""`` returns 1 | ||
|
andyneff marked this conversation as resolved.
Outdated
|
||
| #** | ||
| if [ "${bash_minor_version}" -ge "53" ]; then | ||
| bash_behavior_null_pushd=1 | ||
| bash_behavior_multiline_caller=1 | ||
| else | ||
| bash_behavior_null_pushd=0 | ||
| bash_behavior_multiline_caller=0 | ||
| fi | ||
|
|
||
| #** | ||
| # .. var:: bash_feature_posix_process_substitution | ||
| # | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -364,6 +364,36 @@ function _http_to_git_protocol() | |
| fi | ||
| } | ||
|
|
||
| #** | ||
| # .. function:: git_helper_cdup | ||
| # | ||
| # Helper function to get consistent relative paths from ``--show-cdup`` | ||
| #** | ||
| function git_helper_cdup() | ||
| { | ||
| # Relative path from the CWD to the root of the current repository | ||
| local up_path="$("${GIT}" rev-parse --show-cdup)" | ||
| # Remove trailing / which might be inconsistently added | ||
| up_path="${up_path%/}" | ||
| # handle empty string as . | ||
| echo "${up_path:-.}" | ||
| } | ||
|
|
||
| #** | ||
| # .. function:: git_helper_toplevel | ||
| # | ||
| # Helper function to get consistent relative paths from ``--show-toplevel`` | ||
| #** | ||
| function git_helper_toplevel() | ||
| { | ||
| # The absolute path to the current repository/submodule work tree; e.g., | ||
| # from /src/vsi_common/docker/recipes/hooks, this command prints | ||
| # /src/vsi_common/docker/recipes | ||
| local toplevel="$("${GIT}" rev-parse --show-toplevel 2> /dev/null)" | ||
| # Strip trailing / (this may be guaranteed by --show-toplevel) | ||
| echo "${toplevel%/}" | ||
| } | ||
|
|
||
| #** | ||
| # .. function:: is_submodule | ||
| # | ||
|
|
@@ -372,19 +402,14 @@ function _http_to_git_protocol() | |
|
|
||
| function is_submodule() | ||
| { | ||
| local toplevel="$("${GIT}" rev-parse --show-toplevel 2> /dev/null)" | ||
| # Strip trailing / (this may be guaranteed by --show-toplevel) | ||
| toplevel="${toplevel%/}" | ||
| local toplevel="$(git_helper_toplevel)" | ||
| local sm_basename="$(basename "${toplevel}")" | ||
| local is_submod=1 | ||
| pushd "${toplevel}/../" &> /dev/null | ||
| # Are we still in a git repo | ||
| local superlevel="$("${GIT}" rev-parse --show-toplevel 2> /dev/null)" | ||
| local superlevel="$(git_helper_toplevel)" | ||
| if [ -n "${superlevel:+set}" ]; then | ||
| local prefix="$("${GIT}" rev-parse --show-prefix)" | ||
| # Guarantee a trailing / or empty string (this may be guaranteed by | ||
| # --show-prefix) | ||
| prefix="${prefix:+"${prefix%/}/"}" | ||
| local prefix=$("${GIT}" rev-parse --show-prefix) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the trailing / here guaranteed by --show-prefix or something?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and no. If it returns a non-empty value, it appears to be guaranteed. But if it's empty, then clearly, no slash |
||
| pushd "${superlevel}" &> /dev/null | ||
| # In git v1.8.3, git submodule must be run in the toplevel of the | ||
| # working tree | ||
|
|
@@ -404,28 +429,6 @@ function is_submodule() | |
| popd &> /dev/null | ||
| fi | ||
| popd &> /dev/null | ||
| # | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ehh. I'd restore |
||
| # git rev-parse --git-dir | awk -F '/.git' '{print $1}')" | ||
| # The (usually) absolute path to the repository's .git directory or the | ||
| # submodule's equivalent (e.g., .git/modules/docker/recipes); e.g., from | ||
| # /src/vsi_common/linux, this command prints /src/vsi_common/.git | ||
| # git rev-parse --show-toplevel | ||
| # The absolute path to the current repository/submodule work tree; e.g., | ||
| # from /src/vsi_common/docker/recipes/hooks, this command prints | ||
| # /src/vsi_common/docker/recipes | ||
| # git rev-parse --show-cdup | ||
| # The relative path from the CWD to the current repository/submodule | ||
| # work tree; e.g., from /src/vsi_common/docker/recipes/hooks, this command | ||
| # prints ../ Although, from /src/vsi_common/docker/recipes, this | ||
| # command prints '' (unfortunately) | ||
| # git rev-parse --show-prefix | ||
| # The relative path from the current repository/submodule work tree to the | ||
| # CWD | ||
| # git rev-parse --show-superproject-working-tree (available in git v2.13.7) | ||
| # The absolute path to the working tree of the superproject of the current | ||
| # submodule; e.g., from /src/vsi_common/docker/recipes/hooks, this command | ||
| # prints /src/vsi_common | ||
|
|
||
| return "${is_submod}" | ||
| } | ||
|
|
||
|
|
@@ -443,7 +446,7 @@ function is_submodule() | |
| # RE Should mirror git_project_git_dir | ||
| function git_project_root_dir() | ||
| { | ||
| local toplevel="$("${GIT}" rev-parse --show-toplevel 2> /dev/null)" | ||
| local toplevel="$(git_helper_toplevel)" | ||
| if is_submodule; then | ||
| pushd "${toplevel}/../" &> /dev/null | ||
| git_project_root_dir | ||
|
|
@@ -486,7 +489,7 @@ function git_project_git_dir() | |
| # will (unfortunately/surprisingly) not output anything. (Similarly, | ||
| # core.worktree isn't set). Fortunately, in this case, --git-dir is correct | ||
| local dir | ||
| dir="$("${GIT}" rev-parse --show-toplevel)" | ||
| dir="$("${GIT}" rev-parse --show-toplevel)" # Don't use git_helper_toplevel, logic reasons | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heh. I don't get it, but def a good comment |
||
| if [ -z "${dir:+set}" ]; then | ||
| dir="$("${GIT}" rev-parse --git-dir)" | ||
| if [ "${dir}" == "." ]; then | ||
|
|
@@ -584,66 +587,61 @@ function git_submodule_summary() | |
| # If we are not in the top-level directory of the repo, change to it and | ||
| # re-call this function | ||
| # Alternatively, re-write using git_submodule_displaypaths | ||
| local up_path="$("${GIT}" rev-parse --show-cdup)" | ||
| if [ -n "${up_path:+set}" ]; then | ||
| pushd "${up_path}" &> /dev/null | ||
| git_submodule_summary | ||
| popd &> /dev/null | ||
| return | ||
| fi | ||
|
|
||
| echo "Entering ${PWD}" | ||
| local up_path="$(git_helper_cdup)" | ||
| pushd "${up_path}" &> /dev/null | ||
| echo "Entering ${PWD}" | ||
|
|
||
| local OLD_IFS="${IFS}" | ||
| IFS=$'\n' | ||
| local submodule_keys=($(git_submodule_names)) | ||
| IFS="${OLD_IFS}" | ||
| local OLD_IFS="${IFS}" | ||
| IFS=$'\n' | ||
| local submodule_keys=($(git_submodule_names)) | ||
| IFS="${OLD_IFS}" | ||
|
|
||
| local sm_key | ||
| for sm_key in ${submodule_keys[@]+"${submodule_keys[@]}"}; do | ||
| local sm_path="$("${GIT}" config --file .gitmodules --get submodule."${sm_key}".path)" | ||
|
|
||
| # List the changes (in commits) to the working tree of a submodule | ||
| # cf. git submodule summary, which doesn't show that there is modified or | ||
| # staged content, although it does count up differences (ahead/behind) | ||
| # RE The implementation for git submodule summary sm_path [1] and this | ||
| # command, git diff --submodule=log sm_path [2], are not the same | ||
| # RE Unfortunately, both commands only list the first parents [3] | ||
| # Alternatively, git -c status.submoduleSummary=True status sm_path is | ||
| # similar as well | ||
| # REVIEW Because of these limitations, it might be nicer if this function | ||
| # entered into each submodule and ran git log... directly (which is not too | ||
| # hard, see below), which could show the full set of changes (in commits) | ||
| # to the working tree (not only the first parents) | ||
| # RE Could even run git status --porcelain=1 to show changes in the working | ||
| # tree | ||
| # | ||
| # [1] https://github.com/git/git/blob/v2.24.1/git-submodule.sh#L777 | ||
| # [2] https://github.com/git/git/blob/v2.24.1/diff.c#L3400 => | ||
| # https://github.com/git/git/blob/v2.24.1/submodule.c#L613-L640 | ||
| # https://github.com/git/git/blob/v2.24.1/submodule.c#L554-L563 | ||
| # [3] https://github.com/git/git/blob/v2.24.1/submodule.c#L450 | ||
| "${GIT}" diff --submodule=log "${sm_path}" | ||
|
|
||
|
|
||
| # git diff --submodule=log SHA~1..SHA sm_path (or equivalently | ||
| # git log --patch --submodule=log SHA~1..SHA sm_path) can also be used to | ||
| # list the changes (in commits) to a submodule (but again, only the first | ||
| # parents) between two commits in the enclosing repository | ||
| # RE For example, | ||
| # git diff --submodule=log 0088b126~1..0088b126 docker/recipes | ||
| # ~= git log --patch --submodule=log 0088b126~1..0088b126 docker/recipes | ||
| # vs ( cd docker/recipes && git log --graph 18ca5ee9..fe4f42d4 --first-parent ) | ||
| # cf. ( cd docker/recipes && git log --graph 18ca5ee9..fe4f42d4 ) | ||
|
|
||
|
|
||
| if [ -n "${_recursive_summary:+set}" ]; then | ||
| pushd "${sm_path}" &>/dev/null | ||
| # Depth-first traversal | ||
| git_submodule_summary | ||
| popd &>/dev/null | ||
| fi | ||
| done | ||
| local sm_key | ||
| for sm_key in ${submodule_keys[@]+"${submodule_keys[@]}"}; do | ||
| local sm_path="$("${GIT}" config --file .gitmodules --get submodule."${sm_key}".path)" | ||
|
|
||
| # List the changes (in commits) to the working tree of a submodule | ||
| # cf. git submodule summary, which doesn't show that there is modified or | ||
| # staged content, although it does count up differences (ahead/behind) | ||
| # RE The implementation for git submodule summary sm_path [1] and this | ||
| # command, git diff --submodule=log sm_path [2], are not the same | ||
| # RE Unfortunately, both commands only list the first parents [3] | ||
| # Alternatively, git -c status.submoduleSummary=True status sm_path is | ||
| # similar as well | ||
| # REVIEW Because of these limitations, it might be nicer if this function | ||
| # entered into each submodule and ran git log... directly (which is not too | ||
| # hard, see below), which could show the full set of changes (in commits) | ||
| # to the working tree (not only the first parents) | ||
| # RE Could even run git status --porcelain=1 to show changes in the working | ||
| # tree | ||
| # | ||
| # [1] https://github.com/git/git/blob/v2.24.1/git-submodule.sh#L777 | ||
| # [2] https://github.com/git/git/blob/v2.24.1/diff.c#L3400 => | ||
| # https://github.com/git/git/blob/v2.24.1/submodule.c#L613-L640 | ||
| # https://github.com/git/git/blob/v2.24.1/submodule.c#L554-L563 | ||
| # [3] https://github.com/git/git/blob/v2.24.1/submodule.c#L450 | ||
| "${GIT}" diff --submodule=log "${sm_path}" | ||
|
|
||
|
|
||
| # git diff --submodule=log SHA~1..SHA sm_path (or equivalently | ||
| # git log --patch --submodule=log SHA~1..SHA sm_path) can also be used to | ||
| # list the changes (in commits) to a submodule (but again, only the first | ||
| # parents) between two commits in the enclosing repository | ||
| # RE For example, | ||
| # git diff --submodule=log 0088b126~1..0088b126 docker/recipes | ||
| # ~= git log --patch --submodule=log 0088b126~1..0088b126 docker/recipes | ||
| # vs ( cd docker/recipes && git log --graph 18ca5ee9..fe4f42d4 --first-parent ) | ||
| # cf. ( cd docker/recipes && git log --graph 18ca5ee9..fe4f42d4 ) | ||
|
|
||
|
|
||
| if [ -n "${_recursive_summary:+set}" ]; then | ||
| pushd "${sm_path}" &>/dev/null | ||
| # Depth-first traversal | ||
| git_submodule_summary | ||
| popd &>/dev/null | ||
| fi | ||
| done | ||
| popd &> /dev/null | ||
| } | ||
|
|
||
| #** | ||
|
|
@@ -694,8 +692,9 @@ function git_submodule_displaypaths() | |
| recursive_flag=("--recursive") | ||
| fi | ||
|
|
||
| # Slashes are added because that's how the git 1.8.3 compatibility code was originally written | ||
| # Relative path from the CWD to the root of the current repository | ||
| local up_path="$("${GIT}" rev-parse --show-cdup)" | ||
| local up_path="$(git_helper_cdup)/" | ||
| # Relative path from the root of the current repository to the CWD | ||
| local relative_cwd="$("${GIT}" rev-parse --show-prefix)" | ||
| # Guarantee a trailing / or empty string (this probably is guaranteed by | ||
|
|
@@ -717,6 +716,11 @@ function git_submodule_displaypaths() | |
| local submodule_paths | ||
| if [ "${submodule_foreach_rv}" -eq "0" ]; then | ||
| pushd "${up_path}" &> /dev/null | ||
| # The following logic works based off of these variables being empty instead of `./` for proper output | ||
| if [ "${up_path}" = "./" ]; then | ||
| up_path= | ||
| fi | ||
|
|
||
| # In git v1.8.3, git submodule must be run in the toplevel of the working | ||
| # tree | ||
| # git v1.8.3 does not support git -C | ||
|
|
@@ -818,7 +822,8 @@ function git_submodule_urls() | |
|
|
||
| # git submodule foreach must be run from the top-level working tree in | ||
| # git v1.8.3 | ||
| pushd "$("${GIT}" rev-parse --show-cdup)" &> /dev/null | ||
| local git_top_dir="$(git_helper_cdup)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should prob be called up_path or git_up_path. You have something called git_helper_toplevel |
||
| pushd "${git_top_dir}" &> /dev/null | ||
| # Query the URL from the submodule's repository configuration | ||
| # (e.g., .git/modules/docker/recipes/config) | ||
| # REVIEW Should i unset GIT_DIR? | ||
|
|
@@ -909,7 +914,8 @@ function git_submodule_names() | |
|
|
||
| # git submodule foreach must be run from the top-level working tree in | ||
| # git v1.8.3 | ||
| pushd "$("${GIT}" rev-parse --show-cdup)" &> /dev/null | ||
| local git_top_dir="$(git_helper_cdup)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here again |
||
| pushd "${git_top_dir}" &> /dev/null | ||
| "${GIT}" submodule foreach --quiet ${recursive_flag[@]+"${recursive_flag[@]}"} 'echo "${name}"' | ||
| popd &> /dev/null | ||
| # | ||
|
|
@@ -975,7 +981,8 @@ function git_submodule_toplevels() | |
|
|
||
| # git submodule foreach must be run from the top-level working tree in | ||
| # git v1.8.3 | ||
| pushd "$("${GIT}" rev-parse --show-cdup)" &> /dev/null | ||
| local git_top_dir="$(git_helper_cdup)" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and again |
||
| pushd "${git_top_dir}" &> /dev/null | ||
| "${GIT}" submodule foreach --quiet ${recursive_flag[@]+"${recursive_flag[@]}"} \ | ||
| 'if [ "${OS-}" = "Windows_NT" ]; then | ||
| cygpath "${toplevel}" | ||
|
|
@@ -1169,7 +1176,7 @@ function git_submodule_sync() | |
| # If we are not in the top-level directory of the repo, change to it | ||
| # Alternatively, strip the 'git rev-parse --show-cdup' prefix off of each | ||
| # in_displaypath | ||
| local up_path="$("${GIT}" rev-parse --show-cdup)" | ||
| local up_path="$(git_helper_cdup)" | ||
| pushd "${up_path}" &> /dev/null | ||
| _git_submodule_sync "${remote_name}" "${submodule_names[@]}" | ||
| popd &> /dev/null | ||
|
|
@@ -1259,7 +1266,7 @@ function git_submodule_is_published_recursive() | |
| local is_tracked_change_private=0 | ||
|
|
||
| # If we are not in the top-level directory of the repo, change to it | ||
| local up_path="$("${GIT}" rev-parse --show-cdup)" | ||
| local up_path="$(git_helper_cdup)" | ||
| pushd "${up_path}" &> /dev/null | ||
| _git_submodule_is_published_recursive | ||
| popd &> /dev/null | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1037,7 +1037,10 @@ function parse_docker_compose() | |||||||||||||
| # This is one of the few times the directory you are in matters. To create | ||||||||||||||
| # an expected default behavior, switch to the JUSTFILE dir before searching | ||||||||||||||
| # for the docker compose file. | ||||||||||||||
| pushd "${JUST_DOCKER_COMPOSE_DIR-$(dirname "${JUSTFILE}")}" > /dev/null | ||||||||||||||
| # "./_" is used so that when JUSTFILE and JUST_DOCKER_COMPOSE_DIR are unset, | ||||||||||||||
| # it will use that value that is dirnamed and throws away "/_" and results | ||||||||||||||
| # in pushd . to handle the bash 5.3 issue where pushd "" is now an error | ||||||||||||||
|
Comment on lines
+1040
to
+1042
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| pushd "${JUST_DOCKER_COMPOSE_DIR-$(dirname "${JUSTFILE-./_}")}" > /dev/null | ||||||||||||||
| parent_find_files docker-compose.yml docker-compose.yaml | ||||||||||||||
| popd > /dev/null | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.