Skip to content
18 changes: 9 additions & 9 deletions src/bitbucket/bb-pr-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")"
Expand All @@ -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" \
Expand Down
18 changes: 9 additions & 9 deletions src/bitbucket/bb-pr-merge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/bitbucket/bb-pr-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")"
Expand All @@ -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
Expand Down
28 changes: 14 additions & 14 deletions src/bitbucket/bb-repo-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
20 changes: 10 additions & 10 deletions src/bitbucket/bb-repo-delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/bitbucket/bb-repo-edit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" \
Expand Down
8 changes: 4 additions & 4 deletions src/github/gh-notification-delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
18 changes: 9 additions & 9 deletions src/github/gh-pr-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")"
Expand All @@ -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" \
Expand Down
Loading
Loading