+}
+
+create_commit() {
+ echo "" >&2
+ echo "Plan:" >&2
+ echo "1. bump version" >&2
+ echo "2. update NEWS, AUTHORS" >&2
+ echo "3. commit" >&2
+ echo "4. run bin/release again" >&2
+ echo "" >&2
+
+ bump_version
+ edit_news
+
+ git diff
+ confirm "Ready to commit? [Yn] " || exit 1
+ git commit -a -m "v$version_next release"
+
+ echo "Re-exec $0 to continue" >&2
+ exec $0
+}
+
+bump_version() {
+ local current=$version
+ echo "Current version: '$current'" >&2
+ echo -n "Enter next version (empty to abort): " >&2
+ read version_next
+ if [[ -z "$version_next" ]]; then
+ exit 1
+ fi
+ echo "Next version: '$version_next'" >&2
+
+ local current_tuple="${current//./, }"
+ local next_tuple="${version_next//./, }"
+ local version_path="eventlet/__init__.py"
+ echo "Updating file '$version_path'" >&2
+ if ! sed -i '' -e "s/($current_tuple)/($next_tuple)/" "$version_path"; then
+ echo "sed error $?" >&2
+ exit 1
+ fi
+ if git diff --exit-code "$version_path"; then
+ echo "File '$version_path' is not modified" >&2
+ exit 1
+ fi
+ echo "" >&2
+
+ local doc_path="doc/real_index.html"
+ echo "Updating file '$doc_path'" >&2
+ if ! sed -i '' -e "s/$current/$version_next/g" "$doc_path"; then
+ echo "sed error $?" >&2
+ exit 1
+ fi
+ if git diff --exit-code "$doc_path"; then
+ echo "File '$doc_path' is not modified" >&2
+ exit 1
+ fi
+ echo "" >&2
+
+ confirm "Confirm changes? [yN] " || exit 1
+}
+
+edit_news() {
+ echo "Changes since last release:" >&2
+ git log --format='%h %an %s' "v$version"^.. -- || exit 1
+ echo "" >&2
+
+ local editor=$(which edit 2>/dev/null)
+ [[ -z "$editor" ]] && editor="$EDITOR"
+ if [[ -n "$editor" ]]; then
+ if confirm "Open default editor for NEWS and AUTHORS? [Yn] "; then
+ $editor NEWS
+ $editor AUTHORS
+ else
+ confirm "Change files NEWS and AUTHORS manually and press any key"
+ fi
+ else
+ echo "Unable to determine default text editor." >&2
+ confirm "Change files NEWS and AUTHORS manually and press any key"
+ fi
+ echo "" >&2
+
+ if git diff --exit-code NEWS AUTHORS; then
+ echo "Files NEWS and AUTHORS are not modified" >&2
+ exit 1
+ fi
+ echo "" >&2
+
+ confirm "Confirm changes? [yN] " || exit 1