@@ -8,9 +8,13 @@ trap "echo 'Missing parameter'; exit 1" INT TERM EXIT
88username=" $1 "
99password=" $2 "
1010reponame=" $3 "
11- # remote="$4"
1211trap - INT TERM EXIT
1312
13+ spacename=" $username "
14+ if [ $# -ge 4 ]; then
15+ spacename=" $4 "
16+ fi
17+
1418
1519CURL_OPTS=(-u " $username :$password " --silent)
1620
@@ -24,21 +28,11 @@ curl --fail "${CURL_OPTS[@]}" "https://api.bitbucket.org/2.0/user" > /dev/null |
2428
2529reponame=$( echo $reponame | tr ' [:upper:]' ' [:lower:]' )
2630
27- echo " Checking if BitBucket repository \" $username /$reponame \" exists..."
28- curl " ${CURL_OPTS[@]} " " https://api.bitbucket.org/2.0/repositories/$username /$reponame " | grep " error" > /dev/null && (
29- echo " BitBucket repository \" $username /$reponame \" does NOT exist, creating it..."
30- curl -X POST --fail " ${CURL_OPTS[@]} " " https://api.bitbucket.org/2.0/repositories/$username /$reponame " -H " Content-Type: application/json" -d ' {"scm": "git", "is_private": "true"}' > /dev/null
31+ echo " Checking if BitBucket repository \" $spacename /$reponame \" exists..."
32+ curl " ${CURL_OPTS[@]} " " https://api.bitbucket.org/2.0/repositories/$spacename /$reponame " | grep " error" > /dev/null && (
33+ echo " BitBucket repository \" $spacename /$reponame \" does NOT exist, creating it..."
34+ curl -X POST --fail " ${CURL_OPTS[@]} " " https://api.bitbucket.org/2.0/repositories/$spacename /$reponame " -H " Content-Type: application/json" -d ' {"scm": "git", "is_private": "true"}' > /dev/null
3135)
3236
33-
34- # remote=$(echo $remote | tr '[:upper:]' '[:lower:]')
35- #
36- # echo "Checking for remote \"$remote\"..."
37- # git remote get-url "$remote" &> /dev/null || (
38- # echo "Repository has no remote \"$remote\", creating it..."
39- # git remote add "$remote" https://[email protected] /$username/$reponame.git40- # )
41-
42-
4337echo " Pushing to remote..."
44- git push https://" $username :$password " @bitbucket.org/$username /$reponame .git --all --force
38+ git push https://" $username :$password " @bitbucket.org/$spacename /$reponame .git --all --force
0 commit comments