#!/bin/bash

main() {
  local version=$1
  if [[ -z "${version}" ]]; then
    echo "USAGE: $0 1.3.2"
    echo "Provide a new version number as an argument to bump the version"
    echo -n "Current:"
    grep version= setup.py
    return 1
  fi

  # TODO: replace this with the bumpversion pip package, I couldn't
  # figure out how to use that for these files
  sed -i '' "s/version=.*$/version='${version}',/g" setup.py
  sed -i '' "s/__version__ = .*$/__version__ = '${version}',/g" moto/__init__.py

  git checkout -b version-${version}
  # Commit the new version
  git commit setup.py moto/__init__.py -m "bumping to version ${version}"
  # Commit an updated IMPLEMENTATION_COVERAGE.md
  make implementation_coverage || true
  # Open a PR
  open https://github.com/spulec/moto/compare/master...version-${version}
}

main $@
