From abdcad15fdcbee0e30f9af743e8df5171b1d1068 Mon Sep 17 00:00:00 2001 From: Chemaclass Date: Tue, 27 Aug 2024 19:08:56 +0200 Subject: [PATCH] fix: ignore lib/bashunit on editorconfig --- .editorconfig | 3 +++ .env.example | 6 +++--- bin/pre-commit | 13 +++++++++++++ create-pr.sh | 10 ++++------ src/generic.sh | 2 ++ 5 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 bin/pre-commit diff --git a/.editorconfig b/.editorconfig index 24d443d..cee2bd6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,3 +19,6 @@ indent_style = tab [{lib/*,README.md}] indent_size = unset + +[{lib/bashunit}] +indent_size = unset diff --git a/.env.example b/.env.example index d47e23b..b393b60 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ -DEFAULT_PATH=tests -PR_TICKET_LINK_PREFIX=https://your-company.atlassian.net/browse/ -PR_TEMPLATE_DIR=.github/PULL_REQUEST_TEMPLATE.md +DEFAULT_PATH= +PR_TICKET_LINK_PREFIX= +PR_TEMPLATE_DIR= diff --git a/bin/pre-commit b/bin/pre-commit new file mode 100755 index 0000000..a1f7d69 --- /dev/null +++ b/bin/pre-commit @@ -0,0 +1,13 @@ +#!/bin/bash +echo "Running pre-commit checks" + +make pre_commit/run +EXIT_CODE=$? + +if [[ ${EXIT_CODE} -ne 0 ]]; then + echo "Pre Commit checks failed. Please fix the above issues before committing" + exit ${EXIT_CODE} +else + echo "Pre Commit checks passed, no problems found" + exit 0 +fi diff --git a/create-pr.sh b/create-pr.sh index 62914aa..cb49ede 100755 --- a/create-pr.sh +++ b/create-pr.sh @@ -1,15 +1,13 @@ #!/bin/bash -# shellcheck disable=SC2034 - ROOT_DIR="$(dirname "${BASH_SOURCE[0]}")" +# shellcheck disable=SC1091 [[ -f .env ]] && source .env source "$ROOT_DIR/src/pr_format.sh" source "$ROOT_DIR/src/generic.sh" - -[ -f "$ROOT_DIR/src/dev/debug.sh" ] && source "$ROOT_DIR/src/dev/debug.sh" +source "$ROOT_DIR/src/dev/debug.sh" # Template Configuration APP_ROOT_DIR=$(git rev-parse --show-toplevel) || error_and_exit "This directory is not a git repository" @@ -18,7 +16,6 @@ PR_TEMPLATE="$APP_ROOT_DIR/$PR_TEMPLATE_DIR" [ -z "$PR_TEMPLATE" ] && error_and_exit "PR template file $PR_TEMPLATE not found." BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) || error_and_exit "Failed to get the current branch name." -GH_CLI_INSTALLATION_URL="https://cli.github.com/" BASE_BRANCH=${BASE_BRANCH:-"main"} ASSIGNEE=${ASSIGNEE:-"@me"} @@ -34,7 +31,8 @@ validate_base_branch_exists # Push the current branch if ! git push -u origin "$BRANCH_NAME"; then - error_and_exit "Failed to push the current branch to the remote repository. Please check your git remote settings." + error_and_exit "Failed to push the current branch to the remote repository."\ + "Please check your git remote settings." fi # Create the PR with the specified options diff --git a/src/generic.sh b/src/generic.sh index 571c7a1..712143d 100644 --- a/src/generic.sh +++ b/src/generic.sh @@ -1,5 +1,7 @@ #!/bin/bash +GH_CLI_INSTALLATION_URL="https://cli.github.com/" + function error_and_exit() { echo "Error: $1" >&2 exit 1