diff --git a/README.md b/README.md index 3aeaa082..1684a20d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # General Development Scripts -# Git +## Git Helper/Setup/Template scripts for working with git. @@ -9,7 +9,7 @@ Helper/Setup/Template scripts for working with git. -# Ethereum +## Ethereum Helper/Setup/Template scripts for working with Ethereum/Ethereum clients @@ -22,4 +22,4 @@ Helper/Setup/Template scripts for working with Ethereum/Ethereum clients - \ No newline at end of file + diff --git a/db/README.md b/db/README.md index 288ab262..e8676ad7 100644 --- a/db/README.md +++ b/db/README.md @@ -3,10 +3,12 @@ ## Prerequisites ## Linux + * docker needs to be installed * sqlcmd needs to be installed e.g. ``yay -Sy mssql-tools`` ### Mac OS X + * docker needs to be installed * sqlcmd needs to be installed see [mssql-tools](https://ports.macports.org/port/mssql-tools/) @@ -21,9 +23,10 @@ [1] Assumes appropriate license for Redgate SQLCompare These scripts use the following files: + * ``~/.database`` - file containing properties for talking to mssql -``` +```text SERVER=localhost USER=sa PASSWORD=NotTellingYou! @@ -33,9 +36,10 @@ Note: if SERVER is set as localhost then the local docker instance will be used * ``Repo/.database`` => file containing the DatabaseName for synchronising -``` +```text DB=MyDatabaseName ``` + ### Common Command line parameters * ``--server servername`` - overrides the server name in ~/.database @@ -51,21 +55,27 @@ DB=MyDatabaseName * Uses ~/.database to set get the connection details for the database Usage: + ```bash ./install-mssql --data /home/mssql ``` ### ``createmssqldb`` + * Creates a named database reading ``Repo/.database`` for DB name and ``~/.database`` for connection details ### ``updatedb`` + * Updates a named database reading ``Repo/.database`` for DB name and ``~/.database`` for connection details reading the db schema from ``Repo/db`` folder. ### ``extractdb`` + * Saves a named database reading ``Repo/.database`` for DB name and ``~/.database`` for connection details saving the db schema from ``Repo/db`` folder. Note: + * this does not update the content of static data tables ### ``dbappsettings`` + * Creates\updates appsettings-local.json in each project with the connection string to the DB diff --git a/development/pre-commit-check b/development/pre-commit-check new file mode 100755 index 00000000..542cf7bb --- /dev/null +++ b/development/pre-commit-check @@ -0,0 +1,46 @@ +#! /bin/sh + +die() { + if [ -t 2 ]; then + printf '\n\033[31m✗\033[0m %s\n' "$*" >&2 + else + printf '\n✗ %s\n' "$*" >&2 + fi + exit 1 +} + +success() { + if [ -t 1 ]; then + printf '\n\033[32m✓\033[0m %s\n' "$*" + else + printf '\n✓ %s\n' "$*" + fi +} + +info() { + if [ -t 1 ]; then + printf '\n\033[32m→\033[0m %s\n' "$*" + else + printf '\n→ %s\n' "$*" + fi +} + +# Same check at every level: does /pre-commit exist and is it +# executable? Tried in order: repo's own hooks folder, system, global. +hook_in() { + [ -n "$1" ] && [ -x "$1/pre-commit" ] && printf '%s/pre-commit\n' "$1" +} + +GIT_DIR=$(git rev-parse --absolute-git-dir 2>/dev/null) +REPO_HOOKS_DIR="" +[ -n "$GIT_DIR" ] && REPO_HOOKS_DIR="$GIT_DIR/hooks" +HOOK=$(hook_in "$REPO_HOOKS_DIR") + +[ -n "$HOOK" ] || HOOK=$(hook_in "$(git config --system --get core.hooksPath 2>/dev/null)") +[ -n "$HOOK" ] || HOOK=$(hook_in "$(git config --global --get core.hooksPath 2>/dev/null)") + +[ -n "$HOOK" ] || die "No pre-commit hook found in the repo's hooks folder, system hooksPath, or global hooksPath" + +info "Running $HOOK --all-files" +"$HOOK" --all-files || die "pre-commit hook failed" +success "Pre-commit checks passed"