Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/bash/git/lib_git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ __base_bash_libs_git_path_matches_allowed_path__() {
}

__base_bash_libs_git_only_path_dirty__() {
(($# == 1)) || return 1
(($# == 2)) || return 1

local allowed_path="$1"
local repo_dir="$1" allowed_path="$2"
local status_file status_record status_code path related_path

base_std_make_temp_file status_file base-git-status || return 1
if ! git status --porcelain=v1 --untracked-files=no --ignore-submodules=none -z > "$status_file"; then
if ! git -C "$repo_dir" status --porcelain=v1 --untracked-files=no --ignore-submodules=none -z > "$status_file"; then
base_std_unregister_cleanup_path "$status_file"
rm -f -- "$status_file"
return 1
Expand Down Expand Up @@ -400,7 +400,7 @@ base_git_update_repo() {
dirty=true
fi
if [[ "$dirty" == true ]]; then
if [[ -n "$allowed_dirty_path" ]] && __base_bash_libs_git_only_path_dirty__ "$allowed_dirty_path"; then
if [[ -n "$allowed_dirty_path" ]] && __base_bash_libs_git_only_path_dirty__ "$git_repo" "$allowed_dirty_path"; then
base_std_log_debug -l base_bash_libs.git "Repo '$git_repo' only has tracked changes in '$allowed_dirty_path'; attempting git pull."
else
base_std_log_debug -l base_bash_libs.git "Repo '$git_repo' has local changes; skipping auto-update. Commit or stash to enable git pull."
Expand Down
12 changes: 5 additions & 7 deletions lib/bash/git/tests/lib_git.bats
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,8 @@ EOF
printf 'local one\n' > "$repo/shared/one.txt"
printf 'local two\n' > "$repo/shared/two.txt"

pushd "$repo" >/dev/null
__base_bash_libs_git_only_path_dirty__ "shared"
__base_bash_libs_git_only_path_dirty__ "$repo" "shared"
rc=$?
popd >/dev/null

[ "$rc" -eq 0 ]
}
Expand All @@ -677,7 +675,7 @@ EOF
printf 'local change\n' >> "$repo/shared/hello world.txt"

pushd "$repo" >/dev/null
__base_bash_libs_git_only_path_dirty__ "shared"
__base_bash_libs_git_only_path_dirty__ "$repo" "shared"
rc=$?
popd >/dev/null

Expand All @@ -698,7 +696,7 @@ EOF

pushd "$repo" >/dev/null
set +e
__base_bash_libs_git_only_path_dirty__ "shared"
__base_bash_libs_git_only_path_dirty__ "$repo" "shared"
rc=$?
set -e
popd >/dev/null
Expand All @@ -718,7 +716,7 @@ EOF

pushd "$repo" >/dev/null
set +e
__base_bash_libs_git_only_path_dirty__ "shared"
__base_bash_libs_git_only_path_dirty__ "$repo" "shared"
rc=$?
set -e
popd >/dev/null
Expand All @@ -737,7 +735,7 @@ EOF
git -C "$repo" mv shared/one.txt shared/two.txt

pushd "$repo" >/dev/null
__base_bash_libs_git_only_path_dirty__ "shared"
__base_bash_libs_git_only_path_dirty__ "$repo" "shared"
rc=$?
popd >/dev/null

Expand Down
Loading