<commit_before>#!/bin/sh
##
##  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
##
set -e
devnull='> /dev/null 2>&1'

readonly ORIG_PWD="$(pwd)"

elog() {
  echo "${0##*/} failed because: $@" 1>&2
}

vlog() {
  if [ "${VERBOSE}" = "yes" ]; then
    echo "$@"
  fi
}

cleanup() {
  local readonly res=$?
  cd "${ORIG_PWD}"

  if [ $res -ne 0 ]; then
    elog "cleanup() trapped error"
  fi

  if [ "${KEEP_RELEASE_DIR}" != "yes" ] && [ -n "${RELEASE_DIR}" ]; then
    rm -rf "${RELEASE_DIR}"
  fi
}

release_usage() {
cat << EOF
  Usage: ${0##*/} [arguments]
    --help: Display this message and exit.
    --keep-release-dir: Keep the release directory after archiving.
    --show-program-output: Show output from each step.
    --verbose: Show more output.
    --version: Dotted version number for this release (loaded from git repo
               if not specified).

  Note: The 7-zip (7za.exe) and NSIS (makensis.exe) command line tools must be
        in your path.

  Builds webmdshow-VERSION.zip:
  webmdshow-VERSION/
    inc/
      vp8decoder.idl
      vp8decoderidl.c
      vp8decoderidl.h
      vp8encoder.idl
      vp8encoderidl.c
      vp8encoderidl.h
      vp9decoder.idl
      vp9decoderidl.c
      vp9decoderidl.h
      vpxdecoder.idl
      vpxdecoderidl.c
      vpxdecoderidl.h
      webmmux.idl
      webmmuxidl.c
      webmmuxidl.h
    src/
      vorbistypes.cc
      vorbistypes.h
      webmtypes.cc
      webmtypes.h
    AUTHORS.TXT
    LICENSE.TXT
    PATENTS.TXT
    README.TXT
    install_webmdshow.exe
    makewebm.exe
    playwebm.exe

  This script must be run from the directory containing the webmdshow
  repository from which the release was built.
EOF
}

tool_in_path() {
  local readonly tool="$1"
  local readonly tool_with_args="$@"
  if ! eval "${tool_with_args}" ${devnull}; then
    elog "${tool} not in path."
    release_usage
    exit 1
  fi
}

trap cleanup EXIT

KEEP_RELEASE_DIR=""
WEBMDSHOW="webmdshow"

# Parse the command line.
while [ -n "$1" ]; do
  case "$1" in
    --help)
      release_usage
      exit
      ;;
    --keep-release-dir)
      KEEP_RELEASE_DIR="yes"
      ;;
    --show-program-output)
      devnull=
      ;;
    --verbose)
      VERBOSE="yes"
      ;;
    --version)
      VERSION="$2"
      shift
      ;;
    --webmdshow)
      WEBMDSHOW="$2"
      shift
      ;;
     *)
      release_usage
      exit 1
      ;;
  esac
  shift
done

tool_in_path 7za.exe
tool_in_path makensis.exe -version  # We must pass -version to makensis; it
                                    # returns a failure code to the shell
                                    # when run without parameters.
if [ -z "${VERSION}" ]; then
  cd "${WEBMDSHOW}"
  VERSION="$(git tag | grep webmdshow | tail -n1 | tr -d "webmdshow-")"
  cd "${ORIG_PWD}"
fi

if [ -z "${VERSION}" ]; then
  elog "Unable to read version from webmdshow repo and none provided."
  exit 1
fi

readonly RELEASE_DIR="webmdshow-${VERSION}"<commit_msg>Use common.sh in release.sh.<commit_after>#!/bin/sh
##
##  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
##
##  Use of this source code is governed by a BSD-style license
##  that can be found in the LICENSE file in the root of the source
##  tree. An additional intellectual property rights grant can be found
##  in the file PATENTS.  All contributing project authors may
##  be found in the AUTHORS file in the root of the source tree.
##
. $(dirname $0)/common/common.sh

cleanup() {
  local readonly res=$?
  cd "${ORIG_PWD}"

  if [ $res -ne 0 ]; then
    elog "cleanup() trapped error"
  fi

  if [ "${KEEP_RELEASE_DIR}" != "yes" ] && [ -n "${RELEASE_DIR}" ]; then
    rm -rf "${RELEASE_DIR}"
  fi
}

release_usage() {
cat << EOF
  Usage: ${0##*/} [arguments]
    --help: Display this message and exit.
    --keep-release-dir: Keep the release directory after archiving.
    --show-program-output: Show output from each step.
    --verbose: Show more output.
    --version: Dotted version number for this release (loaded from git repo
               if not specified).

  Note: The 7-zip (7za.exe) and NSIS (makensis.exe) command line tools must be
        in your path.

  Builds webmdshow-VERSION.zip:
  webmdshow-VERSION/
    inc/
      vp8decoder.idl
      vp8decoderidl.c
      vp8decoderidl.h
      vp8encoder.idl
      vp8encoderidl.c
      vp8encoderidl.h
      vp9decoder.idl
      vp9decoderidl.c
      vp9decoderidl.h
      vpxdecoder.idl
      vpxdecoderidl.c
      vpxdecoderidl.h
      webmmux.idl
      webmmuxidl.c
      webmmuxidl.h
    src/
      vorbistypes.cc
      vorbistypes.h
      webmtypes.cc
      webmtypes.h
    AUTHORS.TXT
    LICENSE.TXT
    PATENTS.TXT
    README.TXT
    install_webmdshow.exe
    makewebm.exe
    playwebm.exe

  This script must be run from the directory containing the webmdshow
  repository from which the release was built.
EOF
}

trap cleanup EXIT

KEEP_RELEASE_DIR=""
WEBMDSHOW="webmdshow"

# Parse the command line.
while [ -n "$1" ]; do
  case "$1" in
    --help)
      release_usage
      exit
      ;;
    --keep-release-dir)
      KEEP_RELEASE_DIR="yes"
      ;;
    --show-program-output)
      devnull=
      ;;
    --verbose)
      VERBOSE="yes"
      ;;
    --version)
      VERSION="$2"
      shift
      ;;
    --webmdshow)
      WEBMDSHOW="$2"
      shift
      ;;
     *)
      release_usage
      exit 1
      ;;
  esac
  shift
done

check_tool 7za.exe
check_tool makensis.exe -version  # We must pass -version to makensis; it
                                  # returns a failure code to the shell
                                  # when run without parameters.
if [ -z "${VERSION}" ]; then
  cd "${WEBMDSHOW}"
  VERSION="$(git tag | grep webmdshow | tail -n1 | tr -d "webmdshow-")"
  cd "${ORIG_PWD}"
fi

if [ -z "${VERSION}" ]; then
  elog "Unable to read version from webmdshow repo and none provided."
  exit 1
fi

readonly RELEASE_DIR="webmdshow-${VERSION}"
{'fraction_non_alphanumeric': 0.11015325670498084, 'fraction_numerical': 0.009259259259259259, 'mean_word_length': 2.256237006237006, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5339314', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2101, 'n_words': 645}