Commit 69f4136b authored by Tomáš Hübelbauer's avatar Tomáš Hübelbauer

Differentiate pre-commit hooks for tests

parent 83876670
......@@ -54,20 +54,7 @@ cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
code .git/hooks/pre-commit
```
`.git/hooks/pre-commit`
```sh
#!/usr/bin/env bash
if [ ! -z "command -v powershell" ]
then
powershell cmd/version-office-files.ps1
elif [ ! -z "command -v pwsh" ]
then
pwsh cmd/version-office-files.ps1
else
echo "PowerShell is not installed."
fi
```
- Paste the contents of (hook/pre-commit.sh)[hook/pre-commit.sh] into `.git/hooks/pre-commit`.
Observe commit diffs to see Office file changes in the XML and TXT files.
......@@ -78,12 +65,17 @@ Open it by clicking on any `.ps1` file with integrated terminal open or running
Run `cmd/run-tests.ps1`.
In this repository, the tests run together with the main script in a pre-commit hook in order to catch any bugs as soon as possible during development.
When using this script as a tool in a repository other than this one, only the main script would be ran as shown in the Git pre-commit hook setup code.
## Licensing
This repository is licensed under the [MIT license](LICENSE.md).
## Contributing
Use (hook/pre-commit-development.sh)[hook/pre-commit-development.sh] when contributing to this repository to also run tests.
See [planned development](doc/tasks.md).
## Studying
......
......@@ -26,14 +26,14 @@
## Add a test for the Git hook code
- Create the Office file
- Set up the Git hook (extract hook code out form the `README.md` file)
- Set up the Git hook by copying over `hook/pre-commit.sh`
- Run Git commit
- Verify extraction directory has been created and text file matches
## Make tests run on each commit in this repo
In normal repo utilizing this script, only the script would run,
but as this is a development repository, tests should run as a
pre-commit hook before the script itself does.
Flesh out `hook/pre-commit-development.sh` to invoke both scripts.
Possibly should utilize GitHub/GitLab CI instead of pre-commit hook?
## Utilize GitHub/GitLab CI on top of the pre-commit hook
This is to capture online editor commits.
# This hook also runs tests and is intended only for this repository.
# For repositories other than this, use `pre-commit.sh`.
#!/usr/bin/env bash
if [ ! -z "command -v powershell" ]
then
powershell cmd/version-office-files.ps1
elif [ ! -z "command -v pwsh" ]
then
pwsh cmd/version-office-files.ps1
else
echo "PowerShell is not installed."
fi
#!/usr/bin/env bash
if [ ! -z "command -v powershell" ]
then
powershell cmd/version-office-files.ps1
elif [ ! -z "command -v pwsh" ]
then
pwsh cmd/version-office-files.ps1
else
echo "PowerShell is not installed."
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment