Skip to content

Commit

Permalink
Add test for git IncludeIf with hasconfig:remote.
Browse files Browse the repository at this point in the history
refs gh-198
  • Loading branch information
xwmx committed Oct 24, 2024
1 parent 0174739 commit 4c2cada
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/git.bats
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,56 @@ load test_helper

# git config ##################################################################

@test "'_git_required()' recognizes git configuration that uses 'includeIf' with 'hasconfig:remote' when inside the specified directory." {
{
export HOME="${_TMP_DIR}"

git config --global user.name "Sample Name"
git config --global user.email "[email protected]"

cat <<HEREDOC > "${_TMP_DIR}/.gitconfig_conditional_include_example"
[user]
name = Example Name
email = [email protected]
HEREDOC

cat <<HEREDOC >> "${_TMP_DIR}/.gitconfig"
[includeIf "hasconfig:remote.*.url:file://${_TMP_DIR}*/**"]
path = ${_TMP_DIR}/.gitconfig_conditional_include_example
HEREDOC

cat "${_TMP_DIR}/.gitconfig"

"${_NB}" init
"${_NB}" add "Sample File.md" --content "Sample content."

"${_NB}" notebooks create "Example Notebook"
"${_NB}" use "Example Notebook"

_setup_remote_repo

"${_NB}" remote set "${_GIT_REMOTE_URL}" <<< "y${_NEWLINE}1${_NEWLINE}"

"${_NB}" add "Example File.md" --content "Example content."
}

run "${_NB}" show home:1 --author

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"

[[ "${status}" -eq 0 ]]
[[ "${output}" == "Sample Name <[email protected]>" ]]

run "${_NB}" show Example\ Notebook:1 --author

printf "\${status}: '%s'\\n" "${status}"
printf "\${output}: '%s'\\n" "${output}"

[[ "${status}" -eq 0 ]]
[[ "${output}" == "Example Name <[email protected]>" ]]
}

@test "'_git_required()' recognizes git configuration that uses 'includeIf' when inside the specified directory." {
{
export HOME="${_TMP_DIR}"
Expand Down

0 comments on commit 4c2cada

Please sign in to comment.