diff --git a/src/bitbucket/bb-pr-create.sh b/src/bitbucket/bb-pr-create.sh index 2eec3b5..f709969 100755 --- a/src/bitbucket/bb-pr-create.sh +++ b/src/bitbucket/bb-pr-create.sh @@ -9,8 +9,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function create_bitbucket_pullrequest() { - local REPO - local WORKSPACE + local repo + local workspace local pr_title local pr_body local source_branch @@ -20,19 +20,19 @@ function create_bitbucket_pullrequest() { local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Name of workspace - WORKSPACE="$2" + workspace="$2" # Checks if the parameter was provided or use the default - if [[ -z "$WORKSPACE" ]]; then - WORKSPACE="$DEF_WORKSPACE" + if [[ -z "$workspace" ]]; then + workspace="$DEF_WORKSPACE" fi pr_title="$(format_pullrequest "title")" @@ -53,7 +53,7 @@ function create_bitbucket_pullrequest() { } } }' # Construct URL endpoint - endpoint="$(build_bb_endpoint "PR" "$WORKSPACE" "$REPO")" + endpoint="$(build_bb_endpoint "PR" "$workspace" "$repo")" # Create the repository using curl response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \ diff --git a/src/bitbucket/bb-pr-merge.sh b/src/bitbucket/bb-pr-merge.sh index a6fa2a1..8914118 100755 --- a/src/bitbucket/bb-pr-merge.sh +++ b/src/bitbucket/bb-pr-merge.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function create_bitbucket_pullrequest() { local pr - local REPO - local WORKSPACE + local repo + local workspace local payload local pr_endpoint local endpoint @@ -27,21 +27,21 @@ function create_bitbucket_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - WORKSPACE="$3" + workspace="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$WORKSPACE" ]]; then + if [[ -z "$workspace" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - WORKSPACE="$DEF_WORKSPACE" + workspace="$DEF_WORKSPACE" fi # Create the JSON payload for the repository @@ -53,7 +53,7 @@ function create_bitbucket_pullrequest() { }' # Construct URL endpoint - pr_endpoint="$(build_bb_endpoint "PR" "$WORKSPACE" "$REPO")" + pr_endpoint="$(build_bb_endpoint "PR" "$workspace" "$repo")" endpoint="$endpoint/$pr/merge" # Create the repository using curl diff --git a/src/bitbucket/bb-pr-update.sh b/src/bitbucket/bb-pr-update.sh index 32b9f16..eac865a 100755 --- a/src/bitbucket/bb-pr-update.sh +++ b/src/bitbucket/bb-pr-update.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function update_bitbucket_pullrequest() { local pr - local REPO - local PROJECT + local repo + local project local up_pr_title local up_pr_body local source_branch @@ -30,21 +30,21 @@ function update_bitbucket_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - PROJECT="$3" + project="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$PROJECT" ]]; then + if [[ -z "$project" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - PROJECT="$DEF_PROJECT" + project="$DEF_PROJECT" fi up_pr_title="$(format_pullrequest "title")" @@ -62,9 +62,9 @@ function update_bitbucket_pullrequest() { } } }' # Construct URL endpoint - #endpoint_url="$API_URL/projects/$PROJECT/repos/$REPO/pull-requests/$pr" + #endpoint_url="$API_URL/projects/$project/repos/$repo/pull-requests/$pr" - pr_endpoint="$(build_bb_endpoint "PR" "$WORKSPACE" "$REPO")" + pr_endpoint="$(build_bb_endpoint "PR" "$workspace" "$repo")" endpoint="$pr_endpoint/$pr" # Create the repository using curl diff --git a/src/bitbucket/bb-repo-create.sh b/src/bitbucket/bb-repo-create.sh index 8db1b45..a47e544 100755 --- a/src/bitbucket/bb-repo-create.sh +++ b/src/bitbucket/bb-repo-create.sh @@ -7,45 +7,45 @@ BITBUCKET_AUTH="Authorization: Basic $(echo -n "$BITBUCKET_USER:$BITBUCKET_APPWD function create_bitbucket_repo() { - local REPO - local WORKSPACE - local PROJECT + local repo + local workspace + local project local payload local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Name of project - PROJECT="$2" + project="$2" # Checks if the parameter was provided or use the default - if [[ -z "$PROJECT" ]]; then - PROJECT="$DEF_PROJECT" + if [[ -z "$project" ]]; then + project="$DEF_PROJECT" fi # Name of workspace - WORKSPACE="$3" + workspace="$3" # Checks if the parameter was provided or use the default - if [[ -z "$WORKSPACE" ]]; then - WORKSPACE="$DEF_WORKSPACE" + if [[ -z "$workspace" ]]; then + workspace="$DEF_WORKSPACE" fi # Create the JSON payload for the repository payload='{"scm": "git", "is_private": true, "project": { - "key": "'"$PROJECT"'" + "key": "'"$project"'" }}' # Construct the API Endpoint - endpoint="https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO" + endpoint="https://api.bitbucket.org/2.0/repositories/$workspace/$repo" # Create Bitbucket repository response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \ diff --git a/src/bitbucket/bb-repo-delete.sh b/src/bitbucket/bb-repo-delete.sh index b924953..34b6523 100755 --- a/src/bitbucket/bb-repo-delete.sh +++ b/src/bitbucket/bb-repo-delete.sh @@ -7,32 +7,32 @@ BITBUCKET_AUTH="Authorization: Basic $(echo -n "$BITBUCKET_USER:$BITBUCKET_APPWD function delete_bitbucket_repo() { - local REPO - local WORKSPACE + local repo + local workspace local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Name of workspace - WORKSPACE="$2" + workspace="$2" # Checks if the parameter was provided or use the default - if [[ -z "$WORKSPACE" ]]; then - WORKSPACE="$DEF_WORKSPACE" + if [[ -z "$workspace" ]]; then + workspace="$DEF_WORKSPACE" fi # Construct API Endpoint - endpoint="https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO" + endpoint="https://api.bitbucket.org/2.0/repositories/$workspace/$repo" # Confirm deletion before proceeding - echo "Are you sure you want to delete the repository '$REPO' (y/N)?" + echo "Are you sure you want to delete the repository '$repo' (y/N)?" read -r confirmation if [[ $confirmation =~ ^[Yy]$ ]]; then diff --git a/src/bitbucket/bb-repo-edit.sh b/src/bitbucket/bb-repo-edit.sh index 07b26e7..9d727a3 100755 --- a/src/bitbucket/bb-repo-edit.sh +++ b/src/bitbucket/bb-repo-edit.sh @@ -7,8 +7,8 @@ BITBUCKET_AUTH="Authorization: Basic $(echo -n "$BITBUCKET_USER:$BITBUCKET_APPWD function edit_bitbucket_repo() { - local REPO - local WORKSPACE + local repo + local workspace local new_description local payload local endpoint @@ -24,26 +24,26 @@ function edit_bitbucket_repo() { fi # Name of repository - REPO="$2" + repo="$2" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Name of workspace - WORKSPACE="$3" + workspace="$3" # Checks if the parameter was provided or use the default - if [[ -z "$WORKSPACE" ]]; then - WORKSPACE="$DEF_WORKSPACE" + if [[ -z "$workspace" ]]; then + workspace="$DEF_WORKSPACE" fi # Create the JSON payload for the repository payload='{"description": "'"$new_description"'"}' # Construct API Endpoint - endpoint="https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO" + endpoint="https://api.bitbucket.org/2.0/repositories/$workspace/$repo" # Edit Bitbucket repository response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PUT "$endpoint" \ diff --git a/src/github/gh-notification-delete.sh b/src/github/gh-notification-delete.sh index 21410ff..e3e8780 100755 --- a/src/github/gh-notification-delete.sh +++ b/src/github/gh-notification-delete.sh @@ -12,21 +12,21 @@ set -euo pipefail function delete_github_notifications() { - local NOTIFICATION_ID + local notification_id local endpoint local response local tmp_file - NOTIFICATION_ID="$1" + notification_id="$1" # Checks if the parameter was provided. - if [[ -z "$NOTIFICATION_ID" ]]; then + if [[ -z "$notification_id" ]]; then echo "Provide id notification to delete" exit 1 fi # API Endpoint - endpoint="https://api.github.com/notifications/threads/$NOTIFICATION_ID" + endpoint="https://api.github.com/notifications/threads/$notification_id" # Delete notifications response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X DELETE "$endpoint" \ diff --git a/src/github/gh-pr-create.sh b/src/github/gh-pr-create.sh index 2a29d21..71915ce 100755 --- a/src/github/gh-pr-create.sh +++ b/src/github/gh-pr-create.sh @@ -9,8 +9,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function create_github_pullrequest() { - local REPO - local OWNER + local repo + local owner local pr_title local pr_body local source_branch @@ -20,19 +20,19 @@ function create_github_pullrequest() { local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Repo owner - OWNER="$2" + owner="$2" # Checks if the parameter was provided or use the default - if [[ -z "$OWNER" ]]; then - OWNER="$DEF_GH_OWNER" + if [[ -z "$owner" ]]; then + owner="$DEF_GH_OWNER" fi pr_title="$(format_pullrequest "title")" @@ -46,7 +46,7 @@ function create_github_pullrequest() { "head":"'"$source_branch"'","base":"'"$target_branch"'"}' # Construct URL endpoint - endpoint="$(build_gh_endpoint "PR" "$OWNER" "$REPO")" + endpoint="$(build_gh_endpoint "PR" "$owner" "$repo")" # Create the repository using curl response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \ diff --git a/src/github/gh-pr-merge.sh b/src/github/gh-pr-merge.sh index 2a84292..cf549ec 100755 --- a/src/github/gh-pr-merge.sh +++ b/src/github/gh-pr-merge.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function merge_github_pullrequest() { local pr - local REPO - local OWNER + local repo + local owner local pr_title local pr_body local source_branch @@ -30,28 +30,28 @@ function merge_github_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$OWNER" ]]; then + if [[ -z "$owner" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - OWNER="$DEF_GH_OWNER" + owner="$DEF_GH_OWNER" fi # Create the JSON payload for the repository payload='{"merge_method":"squash"}' # Construct URL endpoint - pr_endpoint="$(build_gh_endpoint "PR" "$OWNER" "$REPO")" + pr_endpoint="$(build_gh_endpoint "PR" "$owner" "$repo")" endpoint="$pr_endpoint/$pr/merge" # Create the repository using curl diff --git a/src/github/gh-pr-update.sh b/src/github/gh-pr-update.sh index 59299bc..454b930 100755 --- a/src/github/gh-pr-update.sh +++ b/src/github/gh-pr-update.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function update_github_pullrequest() { local pr - local REPO - local OWNER + local repo + local owner local up_pr_title local up_pr_body local source_branch @@ -30,21 +30,21 @@ function update_github_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$OWNER" ]]; then + if [[ -z "$owner" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - OWNER="$DEF_GH_OWNER" + owner="$DEF_GH_OWNER" fi up_pr_title="$(format_pullrequest "title")" @@ -53,8 +53,8 @@ function update_github_pullrequest() { # Create the JSON payload for the repository payload='{"title":"'"$up_pr_title"'", "body":"'"$up_pr_body"'"}' - #pr_url="$API_URL/$OWNER/$REPO/pulls" - pr_endpoint="$(build_gh_endpoint "PR" "$OWNER" "$REPO")" + #pr_url="$API_URL/$owner/$repo/pulls" + pr_endpoint="$(build_gh_endpoint "PR" "$owner" "$repo")" endpoint="$pr_endpoint/$pr" # Create the repository using curl diff --git a/src/github/gh-repo-create.sh b/src/github/gh-repo-create.sh index f967775..712c83b 100755 --- a/src/github/gh-repo-create.sh +++ b/src/github/gh-repo-create.sh @@ -3,21 +3,21 @@ set -euo pipefail function create_github_repo() { - local REPO + local repo local payload local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Create the JSON payload for the repository - payload='{"name": "'"$REPO"'", "private": true}' + payload='{"name": "'"$repo"'", "private": true}' # API Endpoint endpoint="https://api.github.com/user/repos" diff --git a/src/github/gh-repo-delete.sh b/src/github/gh-repo-delete.sh index ad7c455..e7f818a 100755 --- a/src/github/gh-repo-delete.sh +++ b/src/github/gh-repo-delete.sh @@ -3,32 +3,32 @@ set -euo pipefail function delete_github_repo() { - local REPO - local OWNER + local repo + local owner local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Repo owner - OWNER="$2" + owner="$2" # Checks if the parameter was provided or use the default - if [[ -z "$OWNER" ]]; then - OWNER="$DEF_GH_OWNER" + if [[ -z "$owner" ]]; then + owner="$DEF_GH_OWNER" fi # Construct API Endpoint - endpoint="https://api.github.com/repos/$OWNER/$REPO" + endpoint="https://api.github.com/repos/$owner/$repo" # Confirm deletion before proceeding - echo "Are you sure you want to delete the repository '$REPO' (y/N)?" + echo "Are you sure you want to delete the repository '$repo' (y/N)?" read -r confirmation if [[ $confirmation =~ ^[Yy]$ ]]; then diff --git a/src/github/gh-repo-edit.sh b/src/github/gh-repo-edit.sh index a427174..3f25053 100755 --- a/src/github/gh-repo-edit.sh +++ b/src/github/gh-repo-edit.sh @@ -3,8 +3,8 @@ set -euo pipefail function edit_github_repo() { - local REPO - local OWNER + local repo + local owner local new_description local payload local endpoint @@ -20,26 +20,26 @@ function edit_github_repo() { fi # Name of repository - REPO="$2" + repo="$2" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Checks if the parameter was provided or use the default - if [[ -z "$OWNER" ]]; then - OWNER="$DEF_GH_OWNER" + if [[ -z "$owner" ]]; then + owner="$DEF_GH_OWNER" fi # Create the JSON payload for the repository payload='{"description": "'"$new_description"'"}' # Construct API Endpoint - endpoint="https://api.github.com/repos/$OWNER/$REPO" + endpoint="https://api.github.com/repos/$owner/$repo" # Edit the repository using curl response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PATCH "$endpoint" \ diff --git a/src/github/gh-search-repo.sh b/src/github/gh-search-repo.sh index 9e37880..4ff2c47 100755 --- a/src/github/gh-search-repo.sh +++ b/src/github/gh-search-repo.sh @@ -2,21 +2,21 @@ function search_github_repo() { - local QUERY + local query local endpoint local response local tmp_file # String to query - QUERY="$1" + query="$1" # Checks if the parameter was provided - if [[ -z "$QUERY" ]]; then + if [[ -z "$query" ]]; then echo "A query to search is necessary" fi # Construct API Endpoint - endpoint="https://api.github.com/search/repositories?q=$QUERY" + endpoint="https://api.github.com/search/repositories?q=$query" response=$(curl --proto "=https" --tlsv1.2 -sSf -L "$endpoint" \ -H "Accept: application/vnd.github+json" \ diff --git a/src/gitlab/gl-pr-create.sh b/src/gitlab/gl-pr-create.sh index 75e7c51..752ca0c 100755 --- a/src/gitlab/gl-pr-create.sh +++ b/src/gitlab/gl-pr-create.sh @@ -9,8 +9,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function create_gitlab_pullrequest() { - local REPO - local OWNER + local repo + local owner local pr_title local pr_body local source_branch @@ -20,21 +20,21 @@ function create_gitlab_pullrequest() { local response # Name of repository - REPO="$1" + repo="$1" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - OWNER="$2" + owner="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$OWNER" ]]; then + if [[ -z "$owner" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - OWNER="$DEF_GL_OWNER" + owner="$DEF_GL_OWNER" fi pr_title="$(format_pullrequest "title")" @@ -49,7 +49,7 @@ function create_gitlab_pullrequest() { "remove_source_branch":"True", "squash":"True"}' # Construct the endpoint URL - endpoint="$(build_gl_endpoint "PR" "$OWNER" "$REPO")" + endpoint="$(build_gl_endpoint "PR" "$owner" "$repo")" # Create the repository using curl response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \ diff --git a/src/gitlab/gl-pr-merge.sh b/src/gitlab/gl-pr-merge.sh index 0687906..a267ab0 100755 --- a/src/gitlab/gl-pr-merge.sh +++ b/src/gitlab/gl-pr-merge.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function merge_gitlab_pullrequest() { local pr - local REPO - local OWNER + local repo + local owner local payload local endpoint local response @@ -26,28 +26,28 @@ function merge_gitlab_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$OWNER" ]]; then + if [[ -z "$owner" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - OWNER="$DEF_GH_OWNER" + owner="$DEF_GL_OWNER" fi # Create the JSON payload for the repository payload='{"merge_method":"squash"}' # Construct the endpoint URL - pr_endpoint="$(build_gl_endpoint "PR" "$OWNER" "$REPO")" + pr_endpoint="$(build_gl_endpoint "PR" "$owner" "$repo")" endpoint="$pr_endpoint/$pr/merge" # Create the repository using curl diff --git a/src/gitlab/gl-pr-update.sh b/src/gitlab/gl-pr-update.sh index aa15869..7dd1ee4 100755 --- a/src/gitlab/gl-pr-update.sh +++ b/src/gitlab/gl-pr-update.sh @@ -10,8 +10,8 @@ source "$GITNAP/utils/format_pullrequest.sh" function update_gitlab_pullrequest() { local pr - local REPO - local OWNER + local repo + local owner local up_pr_title local up_pr_body local payload @@ -28,21 +28,21 @@ function update_gitlab_pullrequest() { fi # Name of repository - REPO="$2" + repo="$2" # Verifica se o parâmetro foi fornecido - if [[ -z "$REPO" ]]; then + if [[ -z "$repo" ]]; then # Se não foi fornecido, utiliza o nome do diretório atual - REPO=$(basename "$PWD") + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Verifica se o parâmetro foi fornecido - if [[ -z "$OWNER" ]]; then + if [[ -z "$owner" ]]; then # Se não foi fornecido, utiliza o padrão definido em auth.sh - OWNER="$DEF_GH_OWNER" + owner="$DEF_GL_OWNER" fi pr_title="$(format_pullrequest "title")" @@ -52,7 +52,7 @@ function update_gitlab_pullrequest() { payload='{"title":"'"$pr_title"'", "body":"'"$pr_body"'"}' # Construct the endpoint URL - pr_endpoint="$(build_gl_endpoint "PR" "$OWNER" "$REPO")" + pr_endpoint="$(build_gl_endpoint "PR" "$owner" "$repo")" endpoint="$pr_endpoint/$pr" # Create the repository using curl diff --git a/src/gitlab/gl-repo-create.sh b/src/gitlab/gl-repo-create.sh index 85de36f..558a92c 100755 --- a/src/gitlab/gl-repo-create.sh +++ b/src/gitlab/gl-repo-create.sh @@ -3,21 +3,21 @@ set -euo pipefail function create_gitlab_repo() { - local REPO + local repo local payload local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Create the JSON payload for the repository - payload='{"name": "'"$REPO"'", "visibility": "private"}' + payload='{"name": "'"$repo"'", "visibility": "private"}' # Construct API Endpoint endpoint="https://gitlab.com/api/v4/projects" diff --git a/src/gitlab/gl-repo-delete.sh b/src/gitlab/gl-repo-delete.sh index f5d0dbf..5ceecaf 100755 --- a/src/gitlab/gl-repo-delete.sh +++ b/src/gitlab/gl-repo-delete.sh @@ -3,33 +3,33 @@ set -euo pipefail function delete_gitlab_repo() { - local REPO - local OWNER + local repo + local owner local endpoint local response # Name of repository - REPO="$1" + repo="$1" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Repo owner - OWNER="$2" + owner="$2" # Checks if the parameter was provided or use the default - if [[ -z "$OWNER" ]]; then - OWNER="$DEF_GL_OWNER" + if [[ -z "$owner" ]]; then + owner="$DEF_GL_OWNER" fi # Construct API Endpoint - SLASH_ENCODED="%2F" - endpoint="https://gitlab.com/api/v4/projects/$OWNER$SLASH_ENCODED$REPO" + slash_encoded="%2F" + endpoint="https://gitlab.com/api/v4/projects/$owner$slash_encoded$repo" # Confirm deletion before proceeding - echo "Are you sure you want to delete the repository '$REPO' (y/N)?" + echo "Are you sure you want to delete the repository '$repo' (y/N)?" read -r confirmation if [[ $confirmation =~ ^[Yy]$ ]]; then diff --git a/src/gitlab/gl-repo-edit.sh b/src/gitlab/gl-repo-edit.sh index c3a06e3..9cc218a 100755 --- a/src/gitlab/gl-repo-edit.sh +++ b/src/gitlab/gl-repo-edit.sh @@ -3,8 +3,8 @@ set -euo pipefail function edit_gitlab_repo() { - local REPO - local OWNER + local repo + local owner local new_description local payload local endpoint @@ -20,27 +20,27 @@ function edit_gitlab_repo() { fi # Name of repository - REPO="$2" + repo="$2" # Checks if the parameter was provided or use the name of the current directory - if [[ -z "$REPO" ]]; then - REPO=$(basename "$PWD") + if [[ -z "$repo" ]]; then + repo=$(basename "$PWD") fi # Repo owner - OWNER="$3" + owner="$3" # Checks if the parameter was provided or use the default - if [[ -z "$OWNER" ]]; then - OWNER="$DEF_GH_OWNER" + if [[ -z "$owner" ]]; then + owner="$DEF_GL_OWNER" fi # Create the JSON payload for the repository payload='{"description": "'"$new_description"'"}' # Construct API Endpoint - SLASH_ENCODED="%2F" - endpoint="https://gitlab.com/api/v4/projects/$OWNER$SLASH_ENCODED$REPO" + slash_encoded="%2F" + endpoint="https://gitlab.com/api/v4/projects/$owner$slash_encoded$repo" # Edit GitLab repository using curl response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PUT "$endpoint" \ diff --git a/src/gitlab/gl-search-repo.sh b/src/gitlab/gl-search-repo.sh index c3fb54b..a1730eb 100755 --- a/src/gitlab/gl-search-repo.sh +++ b/src/gitlab/gl-search-repo.sh @@ -3,21 +3,21 @@ set -euo pipefail function search_gitlab_repo() { - local QUERY + local query local endpoint local response local tmp_file # String to query - QUERY="$1" + query="$1" # Checks if the parameter was provided - if [[ -z "$QUERY" ]]; then + if [[ -z "$query" ]]; then echo "A query to search is necessary" fi # Construct API Endpoint - endpoint="https://gitlab.com/api/v4/search?scope=projects&search=$QUERY" + endpoint="https://gitlab.com/api/v4/search?scope=projects&search=$query" # CURL and jq response=$(curl --proto "=https" --tlsv1.2 -sSf -L "$endpoint" \ diff --git a/src/gitnap/gn-init-git.sh b/src/gitnap/gn-init-git.sh index 058ba64..d53c4f4 100755 --- a/src/gitnap/gn-init-git.sh +++ b/src/gitnap/gn-init-git.sh @@ -6,17 +6,17 @@ source "$GITNAP/utils/down_license.sh" # Sets up a new Git project with optional .gitignore and license. function initialize_git_repo() { - local REPO + local repo # Get current working directory - REPO=$(basename "$PWD") + repo=$(basename "$PWD") # Initialize Git repository git init --initial-branch=main # Check for existing README.md file if [ ! -f "README.md" ]; then - echo "# $REPO" > README.md + echo "# $repo" > README.md fi git add README.md diff --git a/src/utils/endpoints.sh b/src/utils/endpoints.sh index a532199..7c4609d 100755 --- a/src/utils/endpoints.sh +++ b/src/utils/endpoints.sh @@ -87,12 +87,12 @@ function build_gl_endpoint() { local route local owner local repo - local SLASH_ENCODED + local slash_encoded route="$1" owner="$2" repo="$3" - SLASH_ENCODED="%2F" + slash_encoded="%2F" if [[ -z "$route" || -z "$owner" || -z "$repo" ]]; then echo "Error: route, owner, and repository are required for Gitlab." @@ -102,10 +102,10 @@ function build_gl_endpoint() { # Endpoint selector case "$route" in PR) - endpoint="$GL_URL/$GL_REPO_EP/$owner$SLASH_ENCODED$repo/merge_requests" + endpoint="$GL_URL/$GL_REPO_EP/$owner$slash_encoded$repo/merge_requests" ;; REPOS) - endpoint="$GL_URL/$GL_REPO_EP/$owner$SLASH_ENCODED$repo" + endpoint="$GL_URL/$GL_REPO_EP/$owner$slash_encoded$repo" ;; # ... adicionar outras rotas específicas do Gitlab *)