Last active
February 14, 2017 08:15
-
-
Save lajlev/61e7dc38fedd062159558074c65bd0ab to your computer and use it in GitHub Desktop.
Bitbucket bash commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bbcreate(){ | |
curl -s -S -X POST -v -u lajlev:$BITBUCKET_PASS -H "Content-Type: application/json" \ | |
https://api.bitbucket.org/2.0/repositories/lajlev/$1 \ | |
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }' > /dev/null | |
printf "\n π https://bitbucket.org/lajlev/$1 created\n\n" | |
} | |
function bbdelete(){ | |
read -r -p "Delete https://bitbucket.org/lajlev/$1 ? [y/N] " response | |
response=${response,,} | |
if [[ "$response" =~ ^(yes|y)$ ]] | |
then | |
curl -s -S -X DELETE -u lajlev:$BITBUCKET_PASS https://api.bitbucket.org/2.0/repositories/lajlev/$1 > /dev/null | |
printf "\n π $1 deleted\n\n" | |
else | |
exit 0 | |
fi | |
} | |
function bbinit(){ | |
git init | |
curl -X POST -v -u lajlev:$BITBUCKET_PASS -H "Content-Type: application/json" \ | |
https://api.bitbucket.org/2.0/repositories/lajlev/$1 \ | |
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }' | |
git remote add origin [email protected]:lajlev/$1.git | |
git add . | |
git commit -m "init" | |
git push --set-upstream origin master | |
printf "\nπ¦ git init\nπ https://bitbucket.org/lajlev/$1 created\nπ Pushed\n\n" | |
} | |
function bitbucket() { | |
giturl=$(git config --get remote.origin.url) | |
if [ "$giturl" == "" ] | |
then | |
echo "Not a git repository or no remote.origin.url set" | |
exit 1; | |
fi | |
giturl=${giturl/git\@bitbucket\.org\:/https://bitbucket.org/} | |
giturl=${giturl/\.git/\/src} | |
giturl=${giturl/git@/http://} | |
open $giturl | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment