Initial commit - mkbitbucketrepo - Shell script to create Mercurial and Git repository on Bitbucket
 (HTM) hg clone https://bitbucket.org/iamleot/mkbitbucketrepo
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) changeset b95cef7eed2d3258d58b1f12ab718c647eec5857
 (HTM) Author: Leonardo Taccari <iamleot@gmail.com>
       Date:   Sun, 14 Jan 2018 22:08:15 
       
       Initial commit
       
       Diffstat:
        mkbitbucketrepo.sh |  79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
        1 files changed, 79 insertions(+), 0 deletions(-)
       ---
       diff -r 000000000000 -r b95cef7eed2d mkbitbucketrepo.sh
       --- /dev/null   Thu Jan 01 00:00:00 1970 +0000
       +++ b/mkbitbucketrepo.sh        Sun Jan 14 22:08:15 2018 +0100
       @@ -0,0 +1,79 @@
       +#!/bin/sh
       +
       +
       +#
       +# Print usage information and exit.
       +#
       +usage()
       +{
       +
       +       echo "usage: $0 [-ipw] [-d description] [-s hg|git] -u user -o owner repository"
       +       echo 
       +       echo "options:"
       +       echo "-i                Enable issues"
       +       echo "-p                Make the repository private"
       +       echo "-w                Enable wiki"
       +       echo "-d description    Description of the repository"
       +       echo "-s hg|git         SCM used (by default 'hg')"
       +       echo "-o owner          Owner of the repository"
       +       echo "-u user           Username used to create the repository"
       +
       +       exit 1
       +}
       +
       +# Default values
       +bitbucket_user=""
       +owner=""
       +has_wiki="false"
       +has_issues="false"
       +repo_slug=""
       +scm="hg"
       +is_private="false"
       +description=""
       +
       +while getopts d:io:ps:u:w f; do
       +       case $f in
       +               d) description=$OPTARG;;
       +               i) has_issues="true";;
       +               p) is_private="true";;
       +               o) owner=$OPTARG;;
       +               u) bitbucket_user=$OPTARG;;
       +               s)
       +               scm=$OPTARG;
       +               if [ "$scm" != "hg" ] && [ "$scm" != "git" ]; then
       +                       echo "$0: invalid scm"
       +                       exit 1
       +               fi
       +               ;;
       +               w) has_wiki="true";;
       +               ?) usage;;
       +       esac
       +done
       +shift $((OPTIND - 1))
       +
       +repo_slug="$*"
       +
       +if [ -z "${bitbucket_user}" ]; then
       +       echo "$0: user needed"
       +       exit 1
       +fi
       +if [ -z "${owner}" ]; then
       +       echo "$0: owner needed"
       +       exit 1
       +fi
       +if [ -z "${repo_slug}" ]; then
       +       echo "$0: repository_name needed"
       +       exit 1
       +fi
       +
       +curl -X POST -u ${bitbucket_user} -H "Content-Type: application/json"  \
       +    "https://api.bitbucket.org/2.0/repositories/${owner}/${repo_slug}" \
       +    -d @/dev/stdin << EOF
       +{
       +       "scm": "${scm}",
       +       "has_issue": "${has_issues}",
       +       "has_wiki": "${has_wiki}",
       +       "is_private": "${is_private}",
       +       "description": "${description}"
       +}
       +EOF