<commit_before>#!/usr/bin/env bash

# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Constants. Enter relevant repo information here.
UPSTREAM_REPO="kubernetes-incubator"
CLI="kompose"
GITPATH="$GOPATH/src/github.com/kubernetes-incubator/kompose"

usage() {
  echo "This will prepare $CLI for release!"
  echo ""
  echo "Requirements:"
  echo " git"
  echo " hub"
  echo " github-release"
  echo " github_changelog_generator"
  echo " GITHUB_TOKEN in your env variable"
  echo " "
  echo "Not only that, but you must have permission for:"
  echo " Tagging releases within Github"
  echo ""
}

requirements() {

  if [ "$PWD" != "$GITPATH" ]; then
    echo "ERROR: Must be in the $GITPATH directory"
    exit 0
  fi

  if ! hash git 2>/dev/null; then
    echo "ERROR: No git."
    exit 0
  fi

  if ! hash github-release 2>/dev/null; then
    echo "ERROR: No $GOPATH/bin/github-release. Please run 'go get -v github.com/aktau/github-release'"
    exit 0
  fi

  if ! hash github_changelog_generator 2>/dev/null; then
    echo "ERROR: github_changelog_generator required to generate the change log. Please run 'gem install github_changelog_generator"
    exit 0
  fi

  if ! hash hub 2>/dev/null; then
    echo "ERROR: Hub needed in order to create the relevant PR's. Please install hub @ https://github.com/github/hub"
    exit 0
  fi

  if [[ -z "$GITHUB_TOKEN" ]]; then
    echo "ERROR: export GITHUB_TOKEN=yourtoken needed for using github-release"
    exit 0
  fi
}

# Make sure that upstream had been added to the repo 
init_sync() {
  CURRENT_ORIGIN=`git config --get remote.origin.url`
  CURRENT_UPSTREAM=`git config --get remote.upstream.url`
  ORIGIN="<EMAIL>:$ORIGIN_REPO/$CLI.git"
  UPSTREAM="<EMAIL>:$UPSTREAM_REPO/$CLI.git"

  if [ $CURRENT_ORIGIN != $ORIGIN ]; then
    echo "Origin repo must be set to $ORIGIN"
    exit 0
  fi

  if [ $CURRENT_UPSTREAM != $UPSTREAM ]; then
    echo "Upstream repo must be set to $UPSTREAM"
    exit 0
  fi

  git checkout master
  git fetch upstream
  git merge upstream/master
  git checkout -b release-$1
}

replaceversion() {
  echo "1. Replaced version in version.go"
  sed -i "s/$1/$2/g" cmd/version.go

  echo "2. Replaced README.md versioning"
  sed -i "s/$1/$2/g" README.md
}

changelog() {
  echo "Generating changelog using github-changelog-generator"
  github_changelog_generator $UPSTREAM_REPO/$CLI -t $GITHUB_TOKEN --future-release v$1
}

changelog_github() {
  touch changes.txt
  echo "Write your GitHub changelog here" >> changes.txt<commit_msg>Update version number in setup.md file in release script<commit_after>#!/usr/bin/env bash

# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Constants. Enter relevant repo information here.
UPSTREAM_REPO="kubernetes-incubator"
CLI="kompose"
GITPATH="$GOPATH/src/github.com/kubernetes-incubator/kompose"

usage() {
  echo "This will prepare $CLI for release!"
  echo ""
  echo "Requirements:"
  echo " git"
  echo " hub"
  echo " github-release"
  echo " github_changelog_generator"
  echo " GITHUB_TOKEN in your env variable"
  echo " "
  echo "Not only that, but you must have permission for:"
  echo " Tagging releases within Github"
  echo ""
}

requirements() {

  if [ "$PWD" != "$GITPATH" ]; then
    echo "ERROR: Must be in the $GITPATH directory"
    exit 0
  fi

  if ! hash git 2>/dev/null; then
    echo "ERROR: No git."
    exit 0
  fi

  if ! hash github-release 2>/dev/null; then
    echo "ERROR: No $GOPATH/bin/github-release. Please run 'go get -v github.com/aktau/github-release'"
    exit 0
  fi

  if ! hash github_changelog_generator 2>/dev/null; then
    echo "ERROR: github_changelog_generator required to generate the change log. Please run 'gem install github_changelog_generator"
    exit 0
  fi

  if ! hash hub 2>/dev/null; then
    echo "ERROR: Hub needed in order to create the relevant PR's. Please install hub @ https://github.com/github/hub"
    exit 0
  fi

  if [[ -z "$GITHUB_TOKEN" ]]; then
    echo "ERROR: export GITHUB_TOKEN=yourtoken needed for using github-release"
    exit 0
  fi
}

# Make sure that upstream had been added to the repo 
init_sync() {
  CURRENT_ORIGIN=`git config --get remote.origin.url`
  CURRENT_UPSTREAM=`git config --get remote.upstream.url`
  ORIGIN="<EMAIL>:$ORIGIN_REPO/$CLI.git"
  UPSTREAM="<EMAIL>:$UPSTREAM_REPO/$CLI.git"

  if [ $CURRENT_ORIGIN != $ORIGIN ]; then
    echo "Origin repo must be set to $ORIGIN"
    exit 0
  fi

  if [ $CURRENT_UPSTREAM != $UPSTREAM ]; then
    echo "Upstream repo must be set to $UPSTREAM"
    exit 0
  fi

  git checkout master
  git fetch upstream
  git merge upstream/master
  git checkout -b release-$1
}

replaceversion() {
  echo "Replaced version in version.go"
  sed -i "s/$1/$2/g" cmd/version.go

  echo "Replaced version in README.md"
  sed -i "s/$1/$2/g" README.md

  echo "Replaced version in docs/setup.md"
  sed -i "s/$1/$2/g" docs/setup.md
}

changelog() {
  echo "Generating changelog using github-changelog-generator"
  github_changelog_generator $UPSTREAM_REPO/$CLI -t $GITHUB_TOKEN --future-release v$1
}

changelog_github() {
  touch changes.txt
  echo "Write your GitHub changelog here" >> changes.txt
{'fraction_non_alphanumeric': 0.10118286445012788, 'fraction_numerical': 0.008951406649616368, 'mean_word_length': 3.563822027716995, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3171362', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2019, 'n_words': 717}