From abf2972926439ae468c6b239718ec72941a1c5aa Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 12:16:48 -0400 Subject: [PATCH 01/11] verbose logs --- src/scripts/parse_commit_info.sh | 93 +++++++++++++++++--------------- 1 file changed, 51 insertions(+), 42 deletions(-) diff --git a/src/scripts/parse_commit_info.sh b/src/scripts/parse_commit_info.sh index b222d0c..f1f353d 100755 --- a/src/scripts/parse_commit_info.sh +++ b/src/scripts/parse_commit_info.sh @@ -2,7 +2,6 @@ set -e - # Global variable declarations declare -g PARSE_COMMIT_COMMIT_MESSAGE="" declare -g PARSE_COMMIT_COMMIT_HASH="" @@ -13,48 +12,57 @@ declare -g final_commit_message="" ExtractPRNumber() { local commit_msg="$1" - echo "$commit_msg" | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1 || true + echo "Debug: Entering ExtractPRNumber with commit_msg: $commit_msg" >&2 + local result=$(echo "$commit_msg" | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1 || true) + echo "Debug: Exiting ExtractPRNumber with result: $result" >&2 + echo "$result" } FetchCommitMessage() { - git log -1 --pretty=%B || { echo "Fetching commit message failed"; exit 1; } + echo "Debug: Entering FetchCommitMessage" >&2 + local result=$(git log -1 --pretty=%B || { echo "Fetching commit message failed" >&2; exit 1; }) + echo "Debug: Exiting FetchCommitMessage with result: $result" >&2 + echo "$result" } FetchCommitHash() { - git rev-parse HEAD || { echo "Fetching commit hash failed"; exit 1; } + echo "Debug: Entering FetchCommitHash" >&2 + local result=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2; exit 1; }) + echo "Debug: Exiting FetchCommitHash with result: $result" >&2 + echo "$result" } -# Normalize the repository URL for consistent usage GetNormalizedRepoURL() { local circle_repo_url="$1" + echo "Debug: Entering GetNormalizedRepoURL with circle_repo_url: $circle_repo_url" >&2 - + local result if [[ $circle_repo_url == https://* ]]; then - # If it's already an HTTPS URL, just ensure it doesn't have the .git suffix - echo "${circle_repo_url%.git}" + result="${circle_repo_url%.git}" else - # Convert SSH format to https format for consistency - local https_url="${circle_repo_url/git@github.com:/https://github.com/}" - echo "${https_url%.git}" # Strip trailing .git if present + result="${circle_repo_url/git@github.com:/https://github.com/}" + result="${result%.git}" fi + echo "Debug: Exiting GetNormalizedRepoURL with result: $result" >&2 + echo "$result" } ExtractGitHubOrgAndRepo() { local repo_url="$1" + echo "Debug: Entering ExtractGitHubOrgAndRepo with repo_url: $repo_url" >&2 if [[ $repo_url != *github.com* ]]; then echo "Error: Not a GitHub URL." >&2 exit 1 fi - local extracted - extracted=$(echo "$repo_url" | awk -F'/' '{gsub(".git", "", $NF); print $(NF-1), $NF}') + local extracted=$(echo "$repo_url" | awk -F'/' '{gsub(".git", "", $NF); print $(NF-1), $NF}') if [ -z "$extracted" ]; then echo "Error: Invalid GitHub URL format." >&2 exit 1 fi - + echo "Debug: Exiting ExtractGitHubOrgAndRepo with result: $extracted" >&2 echo "$extracted" } @@ -65,65 +73,66 @@ ConstructCommitMessage() { local pr_num="$4" local commit_hash="$5" + echo "Debug: Entering ConstructCommitMessage with org: $org, repo: $repo, commit_msg: $commit_msg, pr_num: $pr_num, commit_hash: $commit_hash" >&2 + local link if [ -n "$pr_num" ]; then link=$(CreatePRLink "$org" "$repo" "$pr_num") else link=$(CreateCommitLink "$org" "$repo" "$commit_hash") fi - echo "orb($repo): $commit_msg $link" + local result="orb($repo): $commit_msg $link" + echo "Debug: Exiting ConstructCommitMessage with result: $result" >&2 + echo "$result" } -# Create PR Link CreatePRLink() { local org="$1" local repo="$2" local pr_number="$3" - echo "https://github.com/$org/$repo/pull/$pr_number" + echo "Debug: Entering CreatePRLink with org: $org, repo: $repo, pr_number: $pr_number" >&2 + local result="https://github.com/$org/$repo/pull/$pr_number" + echo "Debug: Exiting CreatePRLink with result: $result" >&2 + echo "$result" } -# Create Commit Link CreateCommitLink() { local org="$1" local repo="$2" local commit_hash="$3" - echo "https://github.com/$org/$repo/commit/$commit_hash" + echo "Debug: Entering CreateCommitLink with org: $org, repo: $repo, commit_hash: $commit_hash" >&2 + local result="https://github.com/$org/$repo/commit/$commit_hash" + echo "Debug: Exiting CreateCommitLink with result: $result" >&2 + echo "$result" } ParseCommitInfo() { + echo "Debug: Entering ParseCommitInfo" >&2 + if [ "$ORB_TEST_ENV" = "bats-core" ]; then PARSE_COMMIT_REPO_URL=$(GetNormalizedRepoURL "$TEST_REPO_URL") else + echo "Debug: CIRCLE_REPOSITORY_URL before normalization: $CIRCLE_REPOSITORY_URL" >&2 PARSE_COMMIT_REPO_URL=$(GetNormalizedRepoURL "$CIRCLE_REPOSITORY_URL") fi + echo "Debug: PARSE_COMMIT_REPO_URL after normalization: $PARSE_COMMIT_REPO_URL" >&2 + PARSE_COMMIT_COMMIT_MESSAGE=$(FetchCommitMessage) PARSE_COMMIT_COMMIT_HASH=$(FetchCommitHash) - read -r ORG_NAME PARSE_COMMIT_REPO_NAME <<< "$(ExtractGitHubOrgAndRepo "$PARSE_COMMIT_REPO_URL")" - PARSE_COMMIT_PR_NUMBER=$(ExtractPRNumber "$PARSE_COMMIT_COMMIT_MESSAGE") - - final_commit_message=$(ConstructCommitMessage "$ORG_NAME" "$PARSE_COMMIT_REPO_NAME" "$PARSE_COMMIT_COMMIT_MESSAGE" "$PARSE_COMMIT_PR_NUMBER" "$PARSE_COMMIT_COMMIT_HASH") - - echo "$final_commit_message" -} - + local extracted + extracted=$(ExtractGitHubOrgAndRepo "$PARSE_COMMIT_REPO_URL") -ORB_TEST_ENV="bats-core" -if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + local org + local repo + read -r org repo <<<"$extracted" - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } + PARSE_COMMIT_REPO_NAME="$repo" + PARSE_COMMIT_PR_NUMBER=$(ExtractPRNumber "$PARSE_COMMIT_COMMIT_MESSAGE") - final_commit_message="$(ParseCommitInfo)" + final_commit_message=$(ConstructCommitMessage "$org" "$repo" "$PARSE_COMMIT_COMMIT_MESSAGE" "$PARSE_COMMIT_PR_NUMBER" "$PARSE_COMMIT_COMMIT_HASH") + echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 +} - # Logging statements to inspect variables - echo "CIRCLE_REPOSITORY_URL: $CIRCLE_REPOSITORY_URL" - echo "SOURCE_REPO_DIRECTORY: $SOURCE_REPO_DIRECTORY" - echo "PARSE_COMMIT_COMMIT_MESSAGE: $PARSE_COMMIT_COMMIT_MESSAGE" - echo "PARSE_COMMIT_COMMIT_HASH: $PARSE_COMMIT_COMMIT_HASH" - echo "PARSE_COMMIT_REPO_URL: $PARSE_COMMIT_REPO_URL" - echo "PARSE_COMMIT_REPO_NAME: $PARSE_COMMIT_REPO_NAME" - echo "PARSE_COMMIT_PR_NUMBER: $PARSE_COMMIT_PR_NUMBER" - echo "final_commit_message: $final_commit_message" - echo "export FINAL_COMMIT_MESSAGE='$final_commit_message'" >> "$BASH_ENV" -fi +ParseCommitInfo From 35a8b6a5ba8e3fc58ab03877ef68562772ca9e67 Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 12:23:23 -0400 Subject: [PATCH 02/11] check for bats --- src/scripts/parse_commit_info.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/scripts/parse_commit_info.sh b/src/scripts/parse_commit_info.sh index f1f353d..3064a84 100755 --- a/src/scripts/parse_commit_info.sh +++ b/src/scripts/parse_commit_info.sh @@ -107,6 +107,9 @@ CreateCommitLink() { } ParseCommitInfo() { + + cd $SOURCE_REPO_DIRECTORY || { echo "Changing directory failed"; exit 1; } + echo "Debug: Entering ParseCommitInfo" >&2 if [ "$ORB_TEST_ENV" = "bats-core" ]; then @@ -135,4 +138,30 @@ ParseCommitInfo() { echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 } -ParseCommitInfo +ORB_TEST_ENV="bats-core" +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } + + # Check if running in a git repository + if [ ! -d ".git" ]; then + echo "Error: Not a git repository. Exiting." >&2 + exit 1 + fi + + echo "Debug: Entering ParseCommitInfo" >&2 + final_commit_message="$(ParseCommitInfo)" + echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 + + # Logging statements to inspect variables, output to stderr + echo "Debug: CIRCLE_REPOSITORY_URL: $CIRCLE_REPOSITORY_URL" >&2 + echo "Debug: SOURCE_REPO_DIRECTORY: $SOURCE_REPO_DIRECTORY" >&2 + echo "Debug: PARSE_COMMIT_COMMIT_MESSAGE: $PARSE_COMMIT_COMMIT_MESSAGE" >&2 + echo "Debug: PARSE_COMMIT_COMMIT_HASH: $PARSE_COMMIT_COMMIT_HASH" >&2 + echo "Debug: PARSE_COMMIT_REPO_URL: $PARSE_COMMIT_REPO_URL" >&2 + echo "Debug: PARSE_COMMIT_REPO_NAME: $PARSE_COMMIT_REPO_NAME" >&2 + echo "Debug: PARSE_COMMIT_PR_NUMBER: $PARSE_COMMIT_PR_NUMBER" >&2 + echo "Debug: final_commit_message: $final_commit_message" >&2 + + echo "export FINAL_COMMIT_MESSAGE='$final_commit_message'" >> "$BASH_ENV" +fi From 90e8662eba52070f534ce387c51847e0cf91e70c Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 13:05:32 -0400 Subject: [PATCH 03/11] add examples --- src/examples/{example.yml => basic_usage.yml} | 0 src/examples/references.yml | 32 +++++++++++++++++++ 2 files changed, 32 insertions(+) rename src/examples/{example.yml => basic_usage.yml} (100%) create mode 100644 src/examples/references.yml diff --git a/src/examples/example.yml b/src/examples/basic_usage.yml similarity index 100% rename from src/examples/example.yml rename to src/examples/basic_usage.yml diff --git a/src/examples/references.yml b/src/examples/references.yml new file mode 100644 index 0000000..5d78f09 --- /dev/null +++ b/src/examples/references.yml @@ -0,0 +1,32 @@ +description: > + You can reduce repetition by defining props in a YAML anchor and referencing it later. + +usage: + version: 2.1 + orbs: + publish-docs: infinitered/publish-docs@x.y.z # Replace with the actual version + +# Define common parameters +common_params: &publish_docs_params + description: "The description that will appear on autogenerated indexes and components." + git_email: "your.ci@email.here" + git_username: "Your CI Username" + label: "The label that will appear in the sidebar of the docs site." + project_name: 'name-of-project' + source_docs_dir: "docs" + source_repo_directory: "source" + target_docs_dir: "docs" + target_repo: "git@github.com:your-org/your-repo.git" + target_repo_directory: "target" + +workflows: + build_docs: + jobs: + - publish-docs/build_docs: + # this will expand to all the parameters defined in the anchor + <<: *publish_docs_params + publish_to_docs_site: + jobs: + - publish-docs/publish_docs: + # this will expand to all the parameters defined in the anchor + <<: *publish_docs_params From 08108bb8aa8abe0a843758ea1150267e0d0bcf92 Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 13:13:13 -0400 Subject: [PATCH 04/11] change testcondition --- src/scripts/parse_commit_info.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scripts/parse_commit_info.sh b/src/scripts/parse_commit_info.sh index 3064a84..1d615b3 100755 --- a/src/scripts/parse_commit_info.sh +++ b/src/scripts/parse_commit_info.sh @@ -9,6 +9,7 @@ declare -g PARSE_COMMIT_REPO_URL="" declare -g PARSE_COMMIT_REPO_NAME="" declare -g PARSE_COMMIT_PR_NUMBER="" declare -g final_commit_message="" +declare -g ORB_TEST_ENV="bats-core" ExtractPRNumber() { local commit_msg="$1" @@ -112,7 +113,7 @@ ParseCommitInfo() { echo "Debug: Entering ParseCommitInfo" >&2 - if [ "$ORB_TEST_ENV" = "bats-core" ]; then + if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then PARSE_COMMIT_REPO_URL=$(GetNormalizedRepoURL "$TEST_REPO_URL") else echo "Debug: CIRCLE_REPOSITORY_URL before normalization: $CIRCLE_REPOSITORY_URL" >&2 @@ -138,7 +139,6 @@ ParseCommitInfo() { echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 } -ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } @@ -150,6 +150,7 @@ if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then fi echo "Debug: Entering ParseCommitInfo" >&2 + echo "Debug: CIRCLE_REPOSITORY_URL before normalization: $CIRCLE_REPOSITORY_URL" >&2 final_commit_message="$(ParseCommitInfo)" echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 From 2c90859fc73c336757bf5a23a666b61623a8a05a Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 14:59:19 -0400 Subject: [PATCH 05/11] break up parse-commit-info script --- src/commands/commit_and_push_to_target.yml | 3 -- src/commands/extract_github_org_and_repo.yml | 6 +++ src/commands/fetch_commit_info.yml | 6 +++ src/commands/generate_commit_message.yml | 6 +++ src/commands/normalize_repository_url.yml | 6 +++ src/jobs/publish_docs.yml | 4 ++ src/scripts/extract_github_org_and_repo.sh | 41 ++++++++++++++++++++ src/scripts/fetch_commit_info.sh | 35 +++++++++++++++++ src/scripts/generate_commit_message.sh | 31 +++++++++++++++ src/scripts/normalize_repository_url.sh | 27 +++++++++++++ 10 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 src/commands/extract_github_org_and_repo.yml create mode 100644 src/commands/fetch_commit_info.yml create mode 100644 src/commands/generate_commit_message.yml create mode 100644 src/commands/normalize_repository_url.yml create mode 100644 src/scripts/extract_github_org_and_repo.sh create mode 100644 src/scripts/fetch_commit_info.sh create mode 100644 src/scripts/generate_commit_message.sh create mode 100644 src/scripts/normalize_repository_url.sh diff --git a/src/commands/commit_and_push_to_target.yml b/src/commands/commit_and_push_to_target.yml index ab0b019..7a4f084 100644 --- a/src/commands/commit_and_push_to_target.yml +++ b/src/commands/commit_and_push_to_target.yml @@ -2,9 +2,6 @@ description: > "Commits and pushes the updated documentation to the docs repository." steps: - - run: - name: Parse commit message and PR number - command: <> - run: name: Commit and push to target repository command: <> diff --git a/src/commands/extract_github_org_and_repo.yml b/src/commands/extract_github_org_and_repo.yml new file mode 100644 index 0000000..6acb1f2 --- /dev/null +++ b/src/commands/extract_github_org_and_repo.yml @@ -0,0 +1,6 @@ +description: > + "Extracts GitHub organization and repository name from the repository URL." +steps: + - run: + name: "Extract GitHub Organization and Repository" + command: <> diff --git a/src/commands/fetch_commit_info.yml b/src/commands/fetch_commit_info.yml new file mode 100644 index 0000000..d8f203a --- /dev/null +++ b/src/commands/fetch_commit_info.yml @@ -0,0 +1,6 @@ +description: > + "Fetch the last commit message and commit hash from the source repository." +steps: + - run: + name: "Fetch Commit Info" + command: <> diff --git a/src/commands/generate_commit_message.yml b/src/commands/generate_commit_message.yml new file mode 100644 index 0000000..6714e31 --- /dev/null +++ b/src/commands/generate_commit_message.yml @@ -0,0 +1,6 @@ +description: > + "Constructs the final commit message incorporating all relevant details and links." +steps: + - run: + name: "Generate Commit Message" + command: <> diff --git a/src/commands/normalize_repository_url.yml b/src/commands/normalize_repository_url.yml new file mode 100644 index 0000000..24c3f7c --- /dev/null +++ b/src/commands/normalize_repository_url.yml @@ -0,0 +1,6 @@ +description: > + "Normalizes the GitHub URL for use in later parts of the script." +steps: + - run: + name: "Normalize Repository URL" + command: <> diff --git a/src/jobs/publish_docs.yml b/src/jobs/publish_docs.yml index 3608ace..a9b6b09 100644 --- a/src/jobs/publish_docs.yml +++ b/src/jobs/publish_docs.yml @@ -68,4 +68,8 @@ steps: repo_directory: <> - copy_docs_to_target - build_docusaurus + - fetch_commit_info + - normalize_repository_url + - extract_github_org_and_repo + - generate_commit_message - commit_and_push_to_target diff --git a/src/scripts/extract_github_org_and_repo.sh b/src/scripts/extract_github_org_and_repo.sh new file mode 100644 index 0000000..cd5f889 --- /dev/null +++ b/src/scripts/extract_github_org_and_repo.sh @@ -0,0 +1,41 @@ +#! /bin/bash + +# Function to change to the source repository directory +ChangeToSourceRepoDirectory() { + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } +} + +# Function to validate the repository URL and extract organization and repository name +ValidateAndExtractRepoInfo() { + local EXTRACTED + local ORG + local REPO + + # Validate the repository URL + if [[ "$NORMALIZED_REPO_URL" != *github.com* ]]; then + echo "Error: Not a GitHub URL." >&2 + exit 1 + fi + + # Extract GitHub organization and repository name + EXTRACTED=$(echo "$NORMALIZED_REPO_URL" | awk -F'/' '{gsub(".git", "", $NF); print $(NF-1), $NF}') + + if [ -z "$EXTRACTED" ]; then + echo "Error: Invalid GitHub URL format." >&2 + exit 1 + fi + + read -r ORG REPO <<< "$EXTRACTED" + + # Export extracted organization and repository name as environment variables + { + echo "export GITHUB_ORG=\"${ORG}\""; \ + echo "export GITHUB_REPO=\"${REPO}\""; \ + } >> "$BASH_ENV" +} + +# Only call the functions if not in a Bats test environment +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + ChangeToSourceRepoDirectory + ValidateAndExtractRepoInfo +fi diff --git a/src/scripts/fetch_commit_info.sh b/src/scripts/fetch_commit_info.sh new file mode 100644 index 0000000..c851d47 --- /dev/null +++ b/src/scripts/fetch_commit_info.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Function to change to the source repository directory +ChangeToSourceRepoDirectory() { + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } +} + + +# Function to fetch commit information and extract PR number +FetchCommitInfo() { + local PR_NUMBER + local COMMIT_MESSAGE + local COMMIT_HASH + + # Fetch the last commit message and hash + COMMIT_MESSAGE=$(git log -1 --pretty=%B || { echo "Fetching commit message failed"; exit 1; }) + COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed"; exit 1; }) + + # Extract PR number from the commit message using regex + PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))') + PR_NUMBER=${PR_NUMBER:-""} # Set to empty string if no match + + # Export the variables + { + echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" + echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" + echo "export PR_NUMBER=\"$PR_NUMBER\"" + } >> "$BASH_ENV" +} + +# Only call the function if not in a Bats test environment +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + ChangeToSourceRepoDirectory + FetchCommitInfo +fi diff --git a/src/scripts/generate_commit_message.sh b/src/scripts/generate_commit_message.sh new file mode 100644 index 0000000..16935be --- /dev/null +++ b/src/scripts/generate_commit_message.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +GenerateCommitMessage() { + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } + + # Fetch COMMIT_MESSAGE and COMMIT_HASH from git logs + COMMIT_MESSAGE=$(git log -1 --pretty=%B) + COMMIT_HASH=$(git rev-parse HEAD) + + # Check if it's a pull request commit based on the existence of a PR_NUMBER + PR_NUMBER=$(git log -1 --pretty=%B | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1) + + # Differentiate between PR-based and non-PR-based commits + if [ -n "$PR_NUMBER" ]; then + FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE https://github.com/org/$PROJECT_NAME/pull/$PR_NUMBER" + else + FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE ($COMMIT_HASH)" + fi + + # Export variables + { + echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" + echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" + echo "export PR_NUMBER=\"${PR_NUMBER}\"" + echo "export FINAL_COMMIT_MESSAGE=\"${FINAL_COMMIT_MESSAGE}\"" + } >> "$BASH_ENV" +} + +if [ "${0#*"bats-core"}" = "$0" ]; then + GenerateCommitMessage +fi diff --git a/src/scripts/normalize_repository_url.sh b/src/scripts/normalize_repository_url.sh new file mode 100644 index 0000000..8a811c7 --- /dev/null +++ b/src/scripts/normalize_repository_url.sh @@ -0,0 +1,27 @@ +#! /bin/bash + +# Function to change to the source repository directory +ChangeToSourceRepoDirectory() { + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } +} + +# Function to normalize the GitHub URL +NormalizeRepoURL() { + local REPO_URL="$1" + local NORMALIZED_REPO_URL + + if [[ "$REPO_URL" == https://* ]]; then + NORMALIZED_REPO_URL="${REPO_URL%.git}" + else + NORMALIZED_REPO_URL="${REPO_URL/git@github.com:/https://github.com/}" + NORMALIZED_REPO_URL="${NORMALIZED_REPO_URL%.git}" + fi + + echo "export NORMALIZED_REPO_URL=\"${NORMALIZED_REPO_URL}\"" >> "$BASH_ENV" +} + +# Only call the functions if not in a Bats test environment +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + ChangeToSourceRepoDirectory + NormalizeRepoURL "$@" +fi From 4e0ad65229d7e4f9b90b4410f217a7ea5599e813 Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 15:31:39 -0400 Subject: [PATCH 06/11] normalize bash style --- src/scripts/check_docs_exist.sh | 7 +- src/scripts/clone_required_repos.sh | 12 +- src/scripts/commit_and_push_to_target.sh | 19 ++- src/scripts/copy_docs.sh | 27 ++-- src/scripts/create_category_json.sh | 2 +- src/scripts/docusaurus_build.sh | 8 +- src/scripts/extract_github_org_and_repo.sh | 4 +- src/scripts/fetch_commit_info.sh | 7 +- src/scripts/generate_commit_message.sh | 5 +- src/scripts/move_static_content.sh | 7 +- src/scripts/normalize_repository_url.sh | 3 +- src/scripts/parse_commit_info.sh | 168 --------------------- src/scripts/restore_yarn_cache.sh | 19 ++- src/scripts/save_yarn_cache.sh | 13 +- 14 files changed, 80 insertions(+), 221 deletions(-) delete mode 100755 src/scripts/parse_commit_info.sh diff --git a/src/scripts/check_docs_exist.sh b/src/scripts/check_docs_exist.sh index c171ff2..50fcf8e 100755 --- a/src/scripts/check_docs_exist.sh +++ b/src/scripts/check_docs_exist.sh @@ -1,18 +1,19 @@ #!/bin/bash +# Function to check if documents exist in the source directory CheckDocsExist() { # Parameters: Source docs path - echo "Checking if documents exist in the source directory." + echo "Checking if documents exist in the source directory." >&2 # Check if the directory exists if [ ! -d "$FULL_SOURCE_DOCS_PATH" ]; then - echo "Error: Directory $FULL_SOURCE_DOCS_PATH does not exist." + echo "Error: Directory $FULL_SOURCE_DOCS_PATH does not exist." >&2 exit 1 fi # Check if the directory is empty if [ ! "$(ls -A "$FULL_SOURCE_DOCS_PATH")" ]; then - echo "Error: No files found in docs directory." + echo "Error: No files found in docs directory." >&2 exit 1 fi } diff --git a/src/scripts/clone_required_repos.sh b/src/scripts/clone_required_repos.sh index 256ee79..d47cd1b 100644 --- a/src/scripts/clone_required_repos.sh +++ b/src/scripts/clone_required_repos.sh @@ -14,27 +14,27 @@ LogEnvironmentVariables() { # Function to set the Git username and email SetGitUser() { - echo "Configuring Git username and email: $GIT_USERNAME -- $GIT_EMAIL" + echo "Configuring Git username and email: $GIT_USERNAME -- $GIT_EMAIL" >&2 git config --global user.name "$GIT_USERNAME" || { echo "Failed to configure Git username"; exit 1; } git config --global user.email "$GIT_EMAIL" || { echo "Failed to configure Git email"; exit 1; } } # Function to add github.com to known SSH hosts AddGithubToKnownHosts() { - echo "Adding github.com to known SSH hosts" + echo "Adding github.com to known SSH hosts" >&2 mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts || { echo "Failed to add github.com to known hosts"; exit 1; } } # Function to clone the source repository CloneSourceRepo() { - echo "Cloning the $CIRCLE_BRANCH branch of source repository ($CIRCLE_REPOSITORY_URL) to $SOURCE_REPO_DIRECTORY" + echo "Cloning the $CIRCLE_BRANCH branch of source repository ($CIRCLE_REPOSITORY_URL) to $SOURCE_REPO_DIRECTORY" >&2 git clone --branch "$CIRCLE_BRANCH" "$CIRCLE_REPOSITORY_URL" "$SOURCE_REPO_DIRECTORY" || { echo "Failed to clone source repository"; exit 1; } } # Function to clone the target repository CloneTargetRepo() { - echo "Cloning target repository from $TARGET_REPO to $TARGET_REPO_DIRECTORY" + echo "Cloning target repository from $TARGET_REPO to $TARGET_REPO_DIRECTORY" >&2 git clone "$TARGET_REPO" "$TARGET_REPO_DIRECTORY" || { echo "Failed to clone target repository"; exit 1; } ls "$TARGET_REPO_DIRECTORY" } @@ -43,12 +43,10 @@ CloneTargetRepo() { ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then LogEnvironmentVariables - echo "Script is being executed directly" + echo "Script is being executed directly" >&2 SetGitUser AddGithubToKnownHosts CloneSourceRepo CloneTargetRepo -else - echo "Script is being sourced" fi diff --git a/src/scripts/commit_and_push_to_target.sh b/src/scripts/commit_and_push_to_target.sh index c5daf39..3f4ccbb 100755 --- a/src/scripts/commit_and_push_to_target.sh +++ b/src/scripts/commit_and_push_to_target.sh @@ -1,25 +1,24 @@ #! /bin/bash -CommitAndPushToTarget () { -cd "$TARGET_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } +# Function to commit and push changes to the target repository +CommitAndPushToTarget() { + cd "$TARGET_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } -git add docs || { echo "Git add docs failed"; exit 1; } -git add static || { echo "Git add static failed"; exit 1; } +git add docs || { echo "Git add docs failed" >&2; exit 1; } +git add static || { echo "Git add static failed" >&2; exit 1; } if git diff-index --quiet HEAD --; then - echo "No changes" + echo "No changes" >&2 exit 0 -echo "FINAL_COMMIT_MESSAGE: $FINAL_COMMIT_MESSAGE" - else - git commit -m "$FINAL_COMMIT_MESSAGE" || { echo "Git commit failed"; exit 1; } - git push origin main || { echo "Git push failed"; exit 1; } + git commit -m "$FINAL_COMMIT_MESSAGE" || { echo "Git commit failed" >&2; exit 1; } + git push origin main || { echo "Git push failed" >&2; exit 1; } fi } ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then - echo "Final Commit Message: '$FINAL_COMMIT_MESSAGE'" + echo "Final Commit Message: '$FINAL_COMMIT_MESSAGE'" >&2 CommitAndPushToTarget fi diff --git a/src/scripts/copy_docs.sh b/src/scripts/copy_docs.sh index 514eaab..be6c3e1 100755 --- a/src/scripts/copy_docs.sh +++ b/src/scripts/copy_docs.sh @@ -1,36 +1,39 @@ #! /bin/bash +# Function to clear the target repository ClearTarget() { - echo "Clearing the target repository at: $FULL_TARGET_DOCS_PATH/$PROJECT_NAME" + echo "Clearing the target repository at: $FULL_TARGET_DOCS_PATH/$PROJECT_NAME" >&2 # Check if the target path exists if [ -d "$FULL_TARGET_DOCS_PATH/$PROJECT_NAME" ]; then # Remove all content at the target path rm -rf "${FULL_TARGET_DOCS_PATH:?}/$PROJECT_NAME" - echo "Existing docs at ${FULL_TARGET_DOCS_PATH:?}/$PROJECT_NAME removed." + echo "Existing docs at ${FULL_TARGET_DOCS_PATH:?}/$PROJECT_NAME removed." >&2 else - echo "The target directory does not yet exist and will be created." + echo "The target directory does not yet exist and will be created." >&2 fi } +# Function to copy documents to the target repository CopyDocs() { - echo "Copying documents to the target repository." - echo "Source: $FULL_SOURCE_DOCS_PATH" - echo "Destination: $FULL_TARGET_DOCS_PATH" + echo "Copying documents to the target repository." >&2 + echo "Source: $FULL_SOURCE_DOCS_PATH" >&2 + echo "Destination: $FULL_TARGET_DOCS_PATH" >&2 - echo "Clearing the target repository..." + echo "Clearing the target repository..." >&2 ClearTarget - echo "Files to be copied:" + echo "Files to be copied:" >&2 # Log the list of files to be copied - find "$FULL_SOURCE_DOCS_PATH" -type f -print - echo "----" + find "$FULL_SOURCE_DOCS_PATH" -type f -print >&2 + echo "----" >&2 - echo "Copying files..." + echo "Copying files..." >&2 cp -R "$FULL_SOURCE_DOCS_PATH" "$FULL_TARGET_DOCS_PATH/$PROJECT_NAME" - echo "Documents copied successfully." + echo "Documents copied successfully." >&2 } +# Check if the script is being sourced or executed directly ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then CopyDocs diff --git a/src/scripts/create_category_json.sh b/src/scripts/create_category_json.sh index 5bf379a..ffcc915 100755 --- a/src/scripts/create_category_json.sh +++ b/src/scripts/create_category_json.sh @@ -28,7 +28,7 @@ CreateCategoryJSON() { -e "s|\${PROJECT_NAME}|$PROJECT_NAME|g" \ > "$TARGET_REPO_DIRECTORY/docs/$PROJECT_NAME/_category_.json" - echo "_category_.json file created successfully." + echo "_category_.json file created successfully." >&2 } # Check for bats diff --git a/src/scripts/docusaurus_build.sh b/src/scripts/docusaurus_build.sh index 887fc96..de68188 100755 --- a/src/scripts/docusaurus_build.sh +++ b/src/scripts/docusaurus_build.sh @@ -1,10 +1,10 @@ #! /bin/bash DocusaurusBuild() { -echo "Changing to target directory: $TARGET_REPO_DIRECTORY" -cd "$TARGET_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } -echo "Running Docusaurus build..." -yarn build || { echo "Docusaurus build failed"; exit 1; } + echo "Changing to target directory: $TARGET_REPO_DIRECTORY" >&2 + cd "$TARGET_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } + echo "Running Docusaurus build..." >&2 + yarn build || { echo "Docusaurus build failed" >&2; exit 1; } } ORB_TEST_ENV="bats-core" diff --git a/src/scripts/extract_github_org_and_repo.sh b/src/scripts/extract_github_org_and_repo.sh index cd5f889..f711b13 100644 --- a/src/scripts/extract_github_org_and_repo.sh +++ b/src/scripts/extract_github_org_and_repo.sh @@ -34,7 +34,9 @@ ValidateAndExtractRepoInfo() { } >> "$BASH_ENV" } -# Only call the functions if not in a Bats test environment + +# Check for bats +ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory ValidateAndExtractRepoInfo diff --git a/src/scripts/fetch_commit_info.sh b/src/scripts/fetch_commit_info.sh index c851d47..143148a 100644 --- a/src/scripts/fetch_commit_info.sh +++ b/src/scripts/fetch_commit_info.sh @@ -2,7 +2,7 @@ # Function to change to the source repository directory ChangeToSourceRepoDirectory() { - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } } @@ -13,8 +13,8 @@ FetchCommitInfo() { local COMMIT_HASH # Fetch the last commit message and hash - COMMIT_MESSAGE=$(git log -1 --pretty=%B || { echo "Fetching commit message failed"; exit 1; }) - COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed"; exit 1; }) + COMMIT_MESSAGE=$(git log -1 --pretty=%B || { echo "Fetching commit message failed" >&2 ; exit 1; }) + COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2 ; exit 1; }) # Extract PR number from the commit message using regex PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))') @@ -29,6 +29,7 @@ FetchCommitInfo() { } # Only call the function if not in a Bats test environment +ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory FetchCommitInfo diff --git a/src/scripts/generate_commit_message.sh b/src/scripts/generate_commit_message.sh index 16935be..bff25db 100644 --- a/src/scripts/generate_commit_message.sh +++ b/src/scripts/generate_commit_message.sh @@ -1,7 +1,7 @@ #!/bin/bash GenerateCommitMessage() { - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } # Fetch COMMIT_MESSAGE and COMMIT_HASH from git logs COMMIT_MESSAGE=$(git log -1 --pretty=%B) @@ -26,6 +26,7 @@ GenerateCommitMessage() { } >> "$BASH_ENV" } -if [ "${0#*"bats-core"}" = "$0" ]; then +ORB_TEST_ENV="bats-core" +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then GenerateCommitMessage fi diff --git a/src/scripts/move_static_content.sh b/src/scripts/move_static_content.sh index 5b4a3ac..40be268 100755 --- a/src/scripts/move_static_content.sh +++ b/src/scripts/move_static_content.sh @@ -5,16 +5,17 @@ MoveStaticDocs() { # Move static content out of /docs into /static. echo "Checking for static files in the target repository." if [ "$(ls -A "$TARGET_REPO_DIRECTORY/docs/$PROJECT_NAME/_static_")" ]; then - echo "Moving static files." + echo "Moving static files." >&2 mv "$TARGET_REPO_DIRECTORY/docs/$PROJECT_NAME/_static_" "$TARGET_REPO_DIRECTORY/static/$PROJECT_NAME/" - echo "Static files moved successfully." + echo "Static files moved successfully." >&2 else - echo "No static files to copy." + echo "No static files to copy." >&2 fi } ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + ChangeToTargetRepoDirectory MoveStaticDocs fi diff --git a/src/scripts/normalize_repository_url.sh b/src/scripts/normalize_repository_url.sh index 8a811c7..00e8370 100644 --- a/src/scripts/normalize_repository_url.sh +++ b/src/scripts/normalize_repository_url.sh @@ -2,7 +2,7 @@ # Function to change to the source repository directory ChangeToSourceRepoDirectory() { - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } } # Function to normalize the GitHub URL @@ -21,6 +21,7 @@ NormalizeRepoURL() { } # Only call the functions if not in a Bats test environment +ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory NormalizeRepoURL "$@" diff --git a/src/scripts/parse_commit_info.sh b/src/scripts/parse_commit_info.sh deleted file mode 100755 index 1d615b3..0000000 --- a/src/scripts/parse_commit_info.sh +++ /dev/null @@ -1,168 +0,0 @@ -#! /bin/bash - -set -e - -# Global variable declarations -declare -g PARSE_COMMIT_COMMIT_MESSAGE="" -declare -g PARSE_COMMIT_COMMIT_HASH="" -declare -g PARSE_COMMIT_REPO_URL="" -declare -g PARSE_COMMIT_REPO_NAME="" -declare -g PARSE_COMMIT_PR_NUMBER="" -declare -g final_commit_message="" -declare -g ORB_TEST_ENV="bats-core" - -ExtractPRNumber() { - local commit_msg="$1" - echo "Debug: Entering ExtractPRNumber with commit_msg: $commit_msg" >&2 - local result=$(echo "$commit_msg" | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1 || true) - echo "Debug: Exiting ExtractPRNumber with result: $result" >&2 - echo "$result" -} - -FetchCommitMessage() { - echo "Debug: Entering FetchCommitMessage" >&2 - local result=$(git log -1 --pretty=%B || { echo "Fetching commit message failed" >&2; exit 1; }) - echo "Debug: Exiting FetchCommitMessage with result: $result" >&2 - echo "$result" -} - -FetchCommitHash() { - echo "Debug: Entering FetchCommitHash" >&2 - local result=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2; exit 1; }) - echo "Debug: Exiting FetchCommitHash with result: $result" >&2 - echo "$result" -} - -GetNormalizedRepoURL() { - local circle_repo_url="$1" - echo "Debug: Entering GetNormalizedRepoURL with circle_repo_url: $circle_repo_url" >&2 - - local result - if [[ $circle_repo_url == https://* ]]; then - result="${circle_repo_url%.git}" - else - result="${circle_repo_url/git@github.com:/https://github.com/}" - result="${result%.git}" - fi - echo "Debug: Exiting GetNormalizedRepoURL with result: $result" >&2 - echo "$result" -} - -ExtractGitHubOrgAndRepo() { - local repo_url="$1" - echo "Debug: Entering ExtractGitHubOrgAndRepo with repo_url: $repo_url" >&2 - - if [[ $repo_url != *github.com* ]]; then - echo "Error: Not a GitHub URL." >&2 - exit 1 - fi - - local extracted=$(echo "$repo_url" | awk -F'/' '{gsub(".git", "", $NF); print $(NF-1), $NF}') - - if [ -z "$extracted" ]; then - echo "Error: Invalid GitHub URL format." >&2 - exit 1 - fi - echo "Debug: Exiting ExtractGitHubOrgAndRepo with result: $extracted" >&2 - echo "$extracted" -} - -ConstructCommitMessage() { - local org="$1" - local repo="$2" - local commit_msg="$3" - local pr_num="$4" - local commit_hash="$5" - - echo "Debug: Entering ConstructCommitMessage with org: $org, repo: $repo, commit_msg: $commit_msg, pr_num: $pr_num, commit_hash: $commit_hash" >&2 - - local link - if [ -n "$pr_num" ]; then - link=$(CreatePRLink "$org" "$repo" "$pr_num") - else - link=$(CreateCommitLink "$org" "$repo" "$commit_hash") - fi - local result="orb($repo): $commit_msg $link" - echo "Debug: Exiting ConstructCommitMessage with result: $result" >&2 - echo "$result" -} - -CreatePRLink() { - local org="$1" - local repo="$2" - local pr_number="$3" - echo "Debug: Entering CreatePRLink with org: $org, repo: $repo, pr_number: $pr_number" >&2 - local result="https://github.com/$org/$repo/pull/$pr_number" - echo "Debug: Exiting CreatePRLink with result: $result" >&2 - echo "$result" -} - -CreateCommitLink() { - local org="$1" - local repo="$2" - local commit_hash="$3" - echo "Debug: Entering CreateCommitLink with org: $org, repo: $repo, commit_hash: $commit_hash" >&2 - local result="https://github.com/$org/$repo/commit/$commit_hash" - echo "Debug: Exiting CreateCommitLink with result: $result" >&2 - echo "$result" -} - -ParseCommitInfo() { - - cd $SOURCE_REPO_DIRECTORY || { echo "Changing directory failed"; exit 1; } - - echo "Debug: Entering ParseCommitInfo" >&2 - - if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then - PARSE_COMMIT_REPO_URL=$(GetNormalizedRepoURL "$TEST_REPO_URL") - else - echo "Debug: CIRCLE_REPOSITORY_URL before normalization: $CIRCLE_REPOSITORY_URL" >&2 - PARSE_COMMIT_REPO_URL=$(GetNormalizedRepoURL "$CIRCLE_REPOSITORY_URL") - fi - - echo "Debug: PARSE_COMMIT_REPO_URL after normalization: $PARSE_COMMIT_REPO_URL" >&2 - - PARSE_COMMIT_COMMIT_MESSAGE=$(FetchCommitMessage) - PARSE_COMMIT_COMMIT_HASH=$(FetchCommitHash) - - local extracted - extracted=$(ExtractGitHubOrgAndRepo "$PARSE_COMMIT_REPO_URL") - - local org - local repo - read -r org repo <<<"$extracted" - - PARSE_COMMIT_REPO_NAME="$repo" - PARSE_COMMIT_PR_NUMBER=$(ExtractPRNumber "$PARSE_COMMIT_COMMIT_MESSAGE") - - final_commit_message=$(ConstructCommitMessage "$org" "$repo" "$PARSE_COMMIT_COMMIT_MESSAGE" "$PARSE_COMMIT_PR_NUMBER" "$PARSE_COMMIT_COMMIT_HASH") - echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 -} - -if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then - - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } - - # Check if running in a git repository - if [ ! -d ".git" ]; then - echo "Error: Not a git repository. Exiting." >&2 - exit 1 - fi - - echo "Debug: Entering ParseCommitInfo" >&2 - echo "Debug: CIRCLE_REPOSITORY_URL before normalization: $CIRCLE_REPOSITORY_URL" >&2 - final_commit_message="$(ParseCommitInfo)" - echo "Debug: Exiting ParseCommitInfo with final_commit_message: $final_commit_message" >&2 - - # Logging statements to inspect variables, output to stderr - echo "Debug: CIRCLE_REPOSITORY_URL: $CIRCLE_REPOSITORY_URL" >&2 - echo "Debug: SOURCE_REPO_DIRECTORY: $SOURCE_REPO_DIRECTORY" >&2 - echo "Debug: PARSE_COMMIT_COMMIT_MESSAGE: $PARSE_COMMIT_COMMIT_MESSAGE" >&2 - echo "Debug: PARSE_COMMIT_COMMIT_HASH: $PARSE_COMMIT_COMMIT_HASH" >&2 - echo "Debug: PARSE_COMMIT_REPO_URL: $PARSE_COMMIT_REPO_URL" >&2 - echo "Debug: PARSE_COMMIT_REPO_NAME: $PARSE_COMMIT_REPO_NAME" >&2 - echo "Debug: PARSE_COMMIT_PR_NUMBER: $PARSE_COMMIT_PR_NUMBER" >&2 - echo "Debug: final_commit_message: $final_commit_message" >&2 - - echo "export FINAL_COMMIT_MESSAGE='$final_commit_message'" >> "$BASH_ENV" -fi diff --git a/src/scripts/restore_yarn_cache.sh b/src/scripts/restore_yarn_cache.sh index 65c70c6..66e87cc 100644 --- a/src/scripts/restore_yarn_cache.sh +++ b/src/scripts/restore_yarn_cache.sh @@ -1,6 +1,17 @@ #!/bin/bash -echo "Target Repo Directory: $TARGET_REPO_DIRECTORY" -ls "$TARGET_REPO_DIRECTORY" -CACHE_KEY="yarn-cache-$TARGET_REPO_DIRECTORY-$(sha256sum "$TARGET_REPO_DIRECTORY/yarn.lock" | awk '{print $1}')" -circleci cache restore "$CACHE_KEY" + + + +RestoreYarnCache() { + echo "Target Repo Directory: $TARGET_REPO_DIRECTORY" >&2 + CACHE_KEY="yarn-cache-$TARGET_REPO_DIRECTORY-$(sha256sum "$TARGET_REPO_DIRECTORY/yarn.lock" | awk '{print $1}')" + ls "$TARGET_REPO_DIRECTORY" + circleci cache restore "$CACHE_KEY" +} + +# Call the function only if not in a Bats test environment +ORB_TEST_ENV="bats-core" +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + RestoreYarnCache +fi diff --git a/src/scripts/save_yarn_cache.sh b/src/scripts/save_yarn_cache.sh index 064a863..df90411 100644 --- a/src/scripts/save_yarn_cache.sh +++ b/src/scripts/save_yarn_cache.sh @@ -1,3 +1,12 @@ #!/bin/bash -CACHE_KEY="yarn-cache-$TARGET_REPO_DIRECTORY-$(sha256sum "$TARGET_REPO_DIRECTORY"/yarn.lock | awk '{print $1}')" -circleci cache save --key "$CACHE_KEY" --path "$TARGET_REPO_DIRECTORY"/.yarn/cache + +SaveYarnCache() { + CACHE_KEY="yarn-cache-$TARGET_REPO_DIRECTORY-$(sha256sum "$TARGET_REPO_DIRECTORY"/yarn.lock | awk '{print $1}')" + circleci cache save --key "$CACHE_KEY" --path "$TARGET_REPO_DIRECTORY"/.yarn/cache +} + +# Check for bats +ORB_TEST_ENV="bats-core" +if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then + SaveYarnCache +fi From 55a4eb85f0d79c09a85159d5933e03a6f4c48ceb Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 15:34:12 -0400 Subject: [PATCH 07/11] remove obsolete function call --- src/scripts/move_static_content.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scripts/move_static_content.sh b/src/scripts/move_static_content.sh index 40be268..4eed214 100755 --- a/src/scripts/move_static_content.sh +++ b/src/scripts/move_static_content.sh @@ -15,7 +15,6 @@ MoveStaticDocs() { ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then - ChangeToTargetRepoDirectory MoveStaticDocs fi From eddd5dbf69ab2e1b35b18a1eb894b3f375d7bc7e Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 15:47:54 -0400 Subject: [PATCH 08/11] add exit --- src/scripts/fetch_commit_info.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/scripts/fetch_commit_info.sh b/src/scripts/fetch_commit_info.sh index 143148a..7db3262 100644 --- a/src/scripts/fetch_commit_info.sh +++ b/src/scripts/fetch_commit_info.sh @@ -1,26 +1,27 @@ #!/bin/bash +set -x # Enable debugging output -# Function to change to the source repository directory ChangeToSourceRepoDirectory() { - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } + echo "Changing directory to $SOURCE_REPO_DIRECTORY" >&2 + cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory to $SOURCE_REPO_DIRECTORY failed" >&2; exit 1; } } - -# Function to fetch commit information and extract PR number FetchCommitInfo() { local PR_NUMBER local COMMIT_MESSAGE local COMMIT_HASH - # Fetch the last commit message and hash COMMIT_MESSAGE=$(git log -1 --pretty=%B || { echo "Fetching commit message failed" >&2 ; exit 1; }) COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2 ; exit 1; }) - # Extract PR number from the commit message using regex PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))') - PR_NUMBER=${PR_NUMBER:-""} # Set to empty string if no match + PR_NUMBER=${PR_NUMBER:-""} + + if [ -z "$BASH_ENV" ]; then + echo "BASH_ENV is not set" >&2 + exit 1 + fi - # Export the variables { echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" @@ -28,9 +29,10 @@ FetchCommitInfo() { } >> "$BASH_ENV" } -# Only call the function if not in a Bats test environment ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory FetchCommitInfo fi + +exit 0 From ef0d7dba4fbdb1ebd6260bb28a61ae3bc302e165 Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Fri, 13 Oct 2023 16:02:19 -0400 Subject: [PATCH 09/11] remove bash env check --- src/scripts/fetch_commit_info.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/scripts/fetch_commit_info.sh b/src/scripts/fetch_commit_info.sh index 7db3262..0254933 100644 --- a/src/scripts/fetch_commit_info.sh +++ b/src/scripts/fetch_commit_info.sh @@ -12,27 +12,30 @@ FetchCommitInfo() { local COMMIT_HASH COMMIT_MESSAGE=$(git log -1 --pretty=%B || { echo "Fetching commit message failed" >&2 ; exit 1; }) + echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" >&2 COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2 ; exit 1; }) + echo "COMMIT_HASH: $COMMIT_HASH" >&2 PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))') PR_NUMBER=${PR_NUMBER:-""} - if [ -z "$BASH_ENV" ]; then - echo "BASH_ENV is not set" >&2 - exit 1 - fi + # shellcheck disable=SC2086 - { - echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" - echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" - echo "export PR_NUMBER=\"$PR_NUMBER\"" - } >> "$BASH_ENV" + echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" >&2 + echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" >> $BASH_ENV + echo "COMMIT_HASH: $COMMIT_HASH" >&2 + echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" >> $BASH_ENV + echo "PR_NUMBER: $PR_NUMBER" >&2 + echo "export PR_NUMBER=\"$PR_NUMBER\"" >> $BASH_ENV + + exit 0 } ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory FetchCommitInfo + exit 0 fi exit 0 From 3888f736ad6145707b96e565789574f06b315af4 Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Mon, 16 Oct 2023 11:21:57 -0400 Subject: [PATCH 10/11] fix parsing of git info --- src/scripts/extract_github_org_and_repo.sh | 10 ++++---- src/scripts/fetch_commit_info.sh | 14 ++++------- src/scripts/generate_commit_message.sh | 27 ++++++++++++++++++++-- src/scripts/normalize_repository_url.sh | 10 +++++++- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/scripts/extract_github_org_and_repo.sh b/src/scripts/extract_github_org_and_repo.sh index f711b13..6c7a94f 100644 --- a/src/scripts/extract_github_org_and_repo.sh +++ b/src/scripts/extract_github_org_and_repo.sh @@ -1,9 +1,5 @@ #! /bin/bash -# Function to change to the source repository directory -ChangeToSourceRepoDirectory() { - cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed"; exit 1; } -} # Function to validate the repository URL and extract organization and repository name ValidateAndExtractRepoInfo() { @@ -20,6 +16,8 @@ ValidateAndExtractRepoInfo() { # Extract GitHub organization and repository name EXTRACTED=$(echo "$NORMALIZED_REPO_URL" | awk -F'/' '{gsub(".git", "", $NF); print $(NF-1), $NF}') + echo "EXTRACTED: $EXTRACTED" >&2 + if [ -z "$EXTRACTED" ]; then echo "Error: Invalid GitHub URL format." >&2 exit 1 @@ -27,6 +25,9 @@ ValidateAndExtractRepoInfo() { read -r ORG REPO <<< "$EXTRACTED" + echo "ORG: $ORG" >&2 + echo "REPO: $REPO" >&2 + # Export extracted organization and repository name as environment variables { echo "export GITHUB_ORG=\"${ORG}\""; \ @@ -38,6 +39,5 @@ ValidateAndExtractRepoInfo() { # Check for bats ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then - ChangeToSourceRepoDirectory ValidateAndExtractRepoInfo fi diff --git a/src/scripts/fetch_commit_info.sh b/src/scripts/fetch_commit_info.sh index 0254933..e843ab9 100644 --- a/src/scripts/fetch_commit_info.sh +++ b/src/scripts/fetch_commit_info.sh @@ -16,26 +16,20 @@ FetchCommitInfo() { COMMIT_HASH=$(git rev-parse HEAD || { echo "Fetching commit hash failed" >&2 ; exit 1; }) echo "COMMIT_HASH: $COMMIT_HASH" >&2 - PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))') + PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(Merge pull request #\K\d+)|(\(#\K\d+\))' || true) PR_NUMBER=${PR_NUMBER:-""} - # shellcheck disable=SC2086 echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" >&2 - echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" >> $BASH_ENV + echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" >> "$BASH_ENV" echo "COMMIT_HASH: $COMMIT_HASH" >&2 - echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" >> $BASH_ENV + echo "export COMMIT_HASH=\"${COMMIT_HASH}\"" >> "$BASH_ENV" echo "PR_NUMBER: $PR_NUMBER" >&2 - echo "export PR_NUMBER=\"$PR_NUMBER\"" >> $BASH_ENV - - exit 0 + echo "export PR_NUMBER=\"$PR_NUMBER\"" >> "BASH_ENV" } ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory FetchCommitInfo - exit 0 fi - -exit 0 diff --git a/src/scripts/generate_commit_message.sh b/src/scripts/generate_commit_message.sh index bff25db..370741b 100644 --- a/src/scripts/generate_commit_message.sh +++ b/src/scripts/generate_commit_message.sh @@ -1,22 +1,39 @@ #!/bin/bash GenerateCommitMessage() { + echo "Changing directory to $SOURCE_REPO_DIRECTORY" >&2 cd "$SOURCE_REPO_DIRECTORY" || { echo "Changing directory failed" >&2; exit 1; } + echo "Changed directory to $(pwd)" >&2 # Fetch COMMIT_MESSAGE and COMMIT_HASH from git logs COMMIT_MESSAGE=$(git log -1 --pretty=%B) + echo "COMMIT_MESSAGE: $COMMIT_MESSAGE" >&2 + COMMIT_HASH=$(git rev-parse HEAD) + echo "COMMIT_HASH: $COMMIT_HASH" >&2 # Check if it's a pull request commit based on the existence of a PR_NUMBER - PR_NUMBER=$(git log -1 --pretty=%B | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1) + PR_MATCH=$(git log -1 --pretty=%B | grep -o "#[0-9]\+" | grep -o "[0-9]\+" | tail -n 1 || true) # Use "|| true" to prevent exit on failure + if [ -n "$PR_MATCH" ]; then + echo "PR-based commit detected" >&2 + FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE https://github.com/$GITHUB_ORG/$GITHUB_REPO/pull/$PR_MATCH" + else + echo "Non-PR-based commit detected" >&2 + FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE https://github.com/$GITHUB_ORG/$GITHUB_REPO/commit/$COMMIT_HASH" + fi + # Differentiate between PR-based and non-PR-based commits if [ -n "$PR_NUMBER" ]; then - FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE https://github.com/org/$PROJECT_NAME/pull/$PR_NUMBER" + echo "PR-based commit detected" >&2 + FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE https://github.com/$GITHUB_ORG/$PROJECT_NAME/pull/$PR_NUMBER" else + echo "Non-PR-based commit detected" >&2 FINAL_COMMIT_MESSAGE="orb($PROJECT_NAME): $COMMIT_MESSAGE ($COMMIT_HASH)" fi + echo "FINAL_COMMIT_MESSAGE: $FINAL_COMMIT_MESSAGE" >&2 + # Export variables { echo "export COMMIT_MESSAGE=\"${COMMIT_MESSAGE}\"" @@ -24,6 +41,12 @@ GenerateCommitMessage() { echo "export PR_NUMBER=\"${PR_NUMBER}\"" echo "export FINAL_COMMIT_MESSAGE=\"${FINAL_COMMIT_MESSAGE}\"" } >> "$BASH_ENV" + + # Log environment variables + echo "COMMIT_MESSAGE: ${COMMIT_MESSAGE}" >&2 + echo "COMMIT_HASH: ${COMMIT_HASH}" >&2 + echo "PR_NUMBER: ${PR_NUMBER}" >&2 + echo "FINAL_COMMIT_MESSAGE: ${FINAL_COMMIT_MESSAGE}" >&2 } ORB_TEST_ENV="bats-core" diff --git a/src/scripts/normalize_repository_url.sh b/src/scripts/normalize_repository_url.sh index 00e8370..fc70b3d 100644 --- a/src/scripts/normalize_repository_url.sh +++ b/src/scripts/normalize_repository_url.sh @@ -10,13 +10,21 @@ NormalizeRepoURL() { local REPO_URL="$1" local NORMALIZED_REPO_URL + echo "REPO_URL: $REPO_URL" >&2 + if [[ "$REPO_URL" == https://* ]]; then + echo "HTTPS URL detected" >&2 NORMALIZED_REPO_URL="${REPO_URL%.git}" else + echo "SSH URL detected" >&2 NORMALIZED_REPO_URL="${REPO_URL/git@github.com:/https://github.com/}" NORMALIZED_REPO_URL="${NORMALIZED_REPO_URL%.git}" fi + echo "NORMALIZED_REPO_URL: $NORMALIZED_REPO_URL" >&2 + + + echo "export NORMALIZED_REPO_URL=\"${NORMALIZED_REPO_URL}\"" >> "$BASH_ENV" } @@ -24,5 +32,5 @@ NormalizeRepoURL() { ORB_TEST_ENV="bats-core" if [ "${0#*"$ORB_TEST_ENV"}" = "$0" ]; then ChangeToSourceRepoDirectory - NormalizeRepoURL "$@" + NormalizeRepoURL "$CIRCLE_REPOSITORY_URL" fi From 8f60e50c59f06f972160674594e2ad313ce9fafb Mon Sep 17 00:00:00 2001 From: Trevor Coleman Date: Mon, 16 Oct 2023 11:23:44 -0400 Subject: [PATCH 11/11] remove obsolete tests --- src/tests/parse_commit_info.bats | 158 ------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 src/tests/parse_commit_info.bats diff --git a/src/tests/parse_commit_info.bats b/src/tests/parse_commit_info.bats deleted file mode 100644 index d37c06d..0000000 --- a/src/tests/parse_commit_info.bats +++ /dev/null @@ -1,158 +0,0 @@ -#! /bin/bash -# shellcheck disable=SC2031 -# shellcheck disable=SC2030 - -setup() { - export COMMIT_HASH="commitHash1234567890" - export COMMIT_MESSAGE_WITHOUT_PR="Test: Commit message without PR" - export COMMIT_MESSAGE_WITH_PR="Test: Commit message with PR (#42)" - export ORG_NAME="org-name" - export REPO_NAME="repo-name" - export TEST_REPO_URL="https://github.com/org-name/repo-name.git" - export TEST_COMMIT_MESSAGE="$COMMIT_MESSAGE_WITH_PR" -} - -# Mocking git commands and basename -git() { - case "$1" in - log) echo "$TEST_COMMIT_MESSAGE";; - rev-parse) echo "$COMMIT_HASH";; - config) echo "$REPO_URL_MOCK";; - *) return 1;; - esac -} - -# Mock the cd command -cd() { - # Store the directory change in a variable for inspection - # shellcheck disable=SC2034 - LAST_CD_DIRECTORY="$1" - # You can also echo a message to indicate that cd was called, if needed - # echo "cd $1" -} - -basename() { - echo "$REPO_NAME" -} - -# Source the script to get ParseCommitInfo function -source ./src/scripts/parse_commit_info.sh - -@test "FetchCommitMessage: It fetches the last commit message" { - run FetchCommitMessage - [[ "$output" =~ Test:\ Commit\ message\ with\ PR\ \(#42\) ]] -} - -@test "FetchCommitHash: It fetches the commit hash" { - run FetchCommitHash - [[ $output =~ $COMMIT_HASH ]] -} - -@test "GetNormalizedRepoURL: It fetches and normalizes HTTPS repo URL" { - export REPO_URL_MOCK="https://github.com/org-name/repo-name.git" - run GetNormalizedRepoURL $REPO_URL_MOCK - echo "DEBUG: output \"$output\"" - [[ $output == "https://github.com/org-name/repo-name" ]] -} - -@test "GetNormalizedRepoURL: It fetches and normalizes SSH repo URL" { - export REPO_URL_MOCK="git@github.com:org-name/repo-name.git" - run GetNormalizedRepoURL $REPO_URL_MOCK - echo "DEBUG: output \"$output\"" - [[ $output == "https://github.com/org-name/repo-name" ]] -} - -@test "ExtractGitHubOrgAndRepo: It extracts org and repo from HTTPS URL with .git suffix" { - run ExtractGitHubOrgAndRepo "https://github.com/sample-org/sample-repo.git" - [ "$status" -eq 0 ] - [ "$output" = "sample-org sample-repo" ] -} - -@test "ExtractGitHubOrgAndRepo: It extracts org and repo from HTTPS URL without .git suffix" { - run ExtractGitHubOrgAndRepo "https://github.com/sample-org/sample-repo" - [ "$status" -eq 0 ] - [ "$output" = "sample-org sample-repo" ] -} - -@test "ExtractGitHubOrgAndRepo: It throws an error when given an invalid GitHub URL" { - run ExtractGitHubOrgAndRepo "https://invalid.com/sample-org/sample-repo.git" - [ "$status" -eq 1 ] - [[ "$output" == "Error: Not a GitHub URL."* ]] -} - - -@test "ExtractPRNumber: It fetches PR number from commit message" { - run ExtractPRNumber "$COMMIT_MESSAGE_WITH_PR" - [[ $output =~ \42 ]] -} - -@test "ExtractPRNumber: It takes the last possible PR number in messages with multiple potential PR numbers" { - export TEST_COMMIT_MESSAGE="Fix: Commit for testing (#123) (#42)" - run ExtractPRNumber "$TEST_COMMIT_MESSAGE" - echo "DEBUG: output \"$output\"" - [[ $output =~ \42 ]] # Assuming it extracts the last PR number by default -} - -@test "CreatePRLink: It constructs PR link" { - export PR_NUMBER=42 - run CreatePRLink "$ORG_NAME" "$REPO_NAME" "$PR_NUMBER" - [[ $output == https://github.com/org-name/repo-name/pull/42 ]] - unset PR_NUMBER -} - -@test "CreateCommitLink: It constructs commit link" { - run CreateCommitLink "$ORG_NAME" "$REPO_NAME" "$COMMIT_HASH" - [[ $output == "https://github.com/org-name/repo-name/commit/$COMMIT_HASH" ]] -} - - -@test "FetchCommitMessage: It handles commit messages with special characters" { - export TEST_COMMIT_MESSAGE="Fix & Improve: Commit for !testing (#42)" - run FetchCommitMessage - echo "DEBUG: output \"$output\"" - [[ $output =~ Fix\ \&\ Improve:\ Commit\ for\ \!testing\ \(#42\) ]] -} - - -@test "ParseCommitInfo: It handles commit messages with URL-like strings" { - echo "DEBUG: REPO_NAME Before - \"$REPO_NAME\"" >&2 # New Debug Line, directed to stderr - export TEST_COMMIT_MESSAGE="Fix: See https://example.com/issues/42 for more info (#42)" - run ParseCommitInfo - FINAL_MSG=$(echo "$output" | xargs) - echo "DEBUG: REPO_NAME After - \"$REPO_NAME\"" >&2 # New Debug Line, directed to stderr - echo "DEBUG FINAL_MSG: \"$FINAL_MSG\"" >&2 - echo "EXPECTED FINAL_MSG: \"orb($REPO_NAME): $COMMIT_MESSAGE_WITHOUT_PR https://github.com/$ORG_NAME/$REPO_NAME/commit/$COMMIT_HASH\"" >&2 - [[ $FINAL_MSG == "orb($REPO_NAME): Fix: See https://example.com/issues/42 for more info (#42) https://github.com/org-name/repo-name/pull/42" ]] -} - - -@test "ParseCommitInfo: It parses and constructs the final commit message with PR link" { - run ParseCommitInfo - FINAL_MSG=$(echo "$output" | xargs) - echo "DEBUG FINAL_MSG: \"$FINAL_MSG\"" - echo "EXPECTED FINAL_MSG: \"orb($REPO_NAME): $COMMIT_MESSAGE_WITHOUT_PR https://github.com/$ORG_NAME/$REPO_NAME/commit/$COMMIT_HASH\"" - [[ $FINAL_MSG == "orb(repo-name): $COMMIT_MESSAGE_WITH_PR https://github.com/org-name/repo-name/pull/42" ]] -} - -@test "ParseCommitInfo: It parses and constructs the final commit message with commit link" { - export TEST_COMMIT_MESSAGE="$COMMIT_MESSAGE_WITHOUT_PR" - run ParseCommitInfo - FINAL_MSG=$(echo "$output" | xargs) - echo "DEBUG FINAL_MSG: \"$FINAL_MSG\"" - echo "EXPECTED FINAL_MSG: \"orb($REPO_NAME): $COMMIT_MESSAGE_WITHOUT_PR https://github.com/$ORG_NAME/$REPO_NAME/commit/$COMMIT_HASH\"" - [[ $FINAL_MSG == "orb($REPO_NAME): $COMMIT_MESSAGE_WITHOUT_PR https://github.com/$ORG_NAME/$REPO_NAME/commit/$COMMIT_HASH" ]] -} - - -teardown() { - unset COMMIT_HASH - unset COMMIT_MESSAGE - unset COMMIT_MESSAGE_WITHOUT_PR - unset COMMIT_MESSAGE_WITH_PR - unset FINAL_MSG - unset ORG_NAME - unset PR_NUMBER - unset REPO_NAME - unset TEST_REPO_URL - unset TEST_COMMIT_MESSAGE -}