andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

cd to a repo before running git ls-remote #205

Closed me-and closed 2 years ago

me-and commented 2 years ago

This is necessary to allow git ls-remote to pick up repository-specific information, such as values for core.sshCommand or http.userAgent that are stored in the repository's .git/config file.

I'm not sure how best to add coverage for this in the test suites, as all the configuration options that seem relevant to me are ones that require a remote server. Setting up a temporary local HTTP or SSH server as part of the test suites seems like overkill for what is – in my opinion – a very safe change.

I've also not actually managed to run the test suites either. I tried to follow the guide at https://github.com/andsens/homeshick/wiki/Testing, but then running test/run seems to have the test suite return success immediately, even when I deliberately broke a test, while running test/suites/cd.bats first complains that "test/suites/../helper.sh.bash does not exist", then after renaming helper.sh, that "/usr/local/bats/support/load.bash does not exist", and that's a file that doesn't seem to be part of either the abandoned bats repo referenced in the testing page or the currently maintained bats repo. I'm guessing that setup might be something specific to the homebrew packaging of bats...

andsens commented 2 years ago

Thank you for your contribution!
I agree that this is a rather safe change. I have fixed the testing docs. The errors you experience make me think you might be running an old version of bats. Try uninstalling the current version and use the new install steps I have outline in the docs. Alternatively if you use VSCode, there's a devcontainer where everything is set up for you :-)

Merging.

me-and commented 2 years ago

Magic, thank you! I still haven't been able to get the run script to work for testing, but after following the new instructions, for b in *.bats; do bats "$b"; done in the suites directory seems to do the job perfectly adequately for my needs :)