* feat(scp): add -v/--verbose and -i/--interactive flags git scp/git rscp printed a diff via plain `git diff`/`git diff --stat` with no `--no-pager` and no TTY check, blocking on the user's pager. Add -v/--verbose to print the diff via --no-pager before syncing, and -i/--interactive to also prompt for confirmation before the real push/copy. Both apply to git scp and git rscp, and must precede <remote>. Updates man/git-scp.md and Commands.md. * feat(scp): add -n/--dry-run flag Add -n/--dry-run to preview a sync without changing anything: rsync runs with -n, and git add --force / ssh ... rm are skipped outright. Implies --verbose, since confirming or previewing with nothing shown is useless. Also restructures scp_and_stage's push/delete blocks from `&&`-chains into if/then, needed to branch on dry-run, which incidentally fixes a latent bug where a non-TTY COLOR_RESET could silently skip the real rsync/git add/ssh rm calls. Updates man/git-scp.md and Commands.md. * test(scp): add coverage for -n/--dry-run and -i/--interactive abort git-scp had no test coverage at all. Cover the two paths that need no real remote destination: dry-run must preview without touching the index, working tree, or remote path, and declining the interactive confirmation must abort before anything syncs. * feat(scp): Code review * feat(scp): Code review |
||
|---|---|---|
| .. | ||
| bin | ||
| conftest.py | ||
| git-abort.bats | ||
| git-alias.bats | ||
| git-archive-file.bats | ||
| git-authors.bats | ||
| git-browse-ci.bats | ||
| git-browse.bats | ||
| git-continue.bats | ||
| git-scp.bats | ||
| helper.py | ||
| poetry.lock | ||
| pyproject.toml | ||
| README.md | ||
| test_git_abort.py | ||
| test_git_alias.py | ||
| test_git_archive_file.py | ||
| test_git_authors.py | ||
| test_git_browse.py | ||
| test_git_browse_ci.py | ||
| test_git_continue.py | ||
| test_util.sh | ||
Testing
Originally, the tests were written in pytest. However, tests are in the process of being converted to Bats so coverage can be calculated.
Bats Testing
We require a somewhat recent version of Bats. Version v1.8.1 is tested in CI. Once it is installed, the tests can be executed like so:
bats ./tests
We highly recommend adding tests for new features and fixes.
Code Coverage
Coverage can be calculated with bashcov like so:
bashcov -- bats ./tests
By default, the report will be generated in ./coverage/index.html.
Python Testing
The test part depends on:
- python >= 3.11
- poetry >= 1.8.0
- pytest >= 8.1.2
- gitpython >= 3.1.43
So the versions are higher than above is recommended.
How to run the tests
- Install
poetry - Install the dependencies via
poetry install - Run
poetry run pytest
It is done or go without poetry,
- Install python >= 3.11
- Install pytest >= 8.1.2
- Install gitpython >= 3.1.43
- Install testpath >= 0.6.0
- Run
pytest
The second way maybe blocked the some missing dependencies at someday, so the first one is recommended.
What and how to create a unit test
One command has a unit test, because one git-* command is just do one thing, so we can eat a piece of git-* command in one time.
For example,
- The
git-aliasshould have a test suite, so createtest_git_alias.pyin the directorytest - Create a test class
TestGitAliasin thetest_git_alias.py - Create a test case
test_init, and some test fixtures can be used,temp_repo,named_temp_repoetc.temp_repois module scoped fixture which create a temporary directory and available in the test suitetest_git_alias.py.named_temp_repois just same astemp_repoexcept the custom directory renaming.
- Loop the third step until the 100% coverage of the function of the
git-alias