<commit_before>#!/bin/bash

set -e

THIS_SCRIPT=`basename "$0"`

function usage
{
    echo "$THIS_SCRIPT <BZR_URL> <SRC_DIR> [<GPG_KEY>]"
}

function gpg_sign
{
    FILE="$1"
    rm -f "$FILE".sig
    $GPG --batch --use-agent --detach-sign --local-user "$GPG_KEY" \
        "$FILE"
}

function maybe_gpg_sign
{
    [[ -e "$1" ]] && gpg_sign "$1"
}

function command_exists
{
    type "$1" &>/dev/null
}

function find_archiver
{
    command_exists "$1" && echo "$1" || echo ':'
}

BZR_URL="$1"
if [[ -z "$BZR_URL" ]] ; then
    usage
    exit 1
fi

if [[ -z "$2" ]] ; then
    BZR_URL=${BZR_URL%/}
    BZR_BASE_URL=${BZR_URL%/*}
    BZR_BRANCH_NAME=${BZR_URL#$BZR_BASE_URL}
    BZR_BRANCH_NAME=${BZR_BRANCH_NAME#/}
    SRC_DIR=$BZR_BRANCH_NAME
else
    SRC_DIR="$2"
fi

if [[ ! -z "$3" ]] ; then
    GPG_KEY="$3"
else
    GPG_KEY=
fi

DEST_DIR="$PWD"

TMPDIR=${TMPDIR:-${TMP:-${TEMP}}}
if [[ -z "${TMPDIR}" ]] ; then
    unset TMPDIR
else
    export TMPDIR
fi
TMP_DIR=`mktemp -d -t log4cplus.XXXXXXX`
pushd "$TMP_DIR"

TAR=${TAR:-$(find_archiver tar)}
XZ=${XZ:-$(find_archiver xz)}
BZIP2=${BZIP2:-$(find_archiver bzip2)}
GZIP=${GZIP:-$(find_archiver gzip)}
SEVENZA=${SEVENZA:-$(find_archiver 7za)}
LRZIP=${LRZIP:-$(find_archiver lrzip)}
BZR=${BZR:-bzr}
GPG=${GPG:-gpg}

$BZR export --per-file-timestamps -v "$SRC_DIR" "$BZR_URL"
$BZR version-info "$BZR_URL" >"$SRC_DIR/REVISION"

pushd "$SRC_DIR"
$SHELL ./scripts/fix-timestamps.sh
popd<commit_msg>scripts/prepare_dist_from_git.sh: Change to use Git.<commit_after>#!/bin/bash

set -e

THIS_SCRIPT=`basename "$0"`

function usage
{
    echo "$THIS_SCRIPT <GIT_URL> <GIT_BRANCH> [<SRC_DIR>] [<GPG_KEY>]"
}

function gpg_sign
{
    FILE="$1"
    rm -f "$FILE".sig
    $GPG --batch --use-agent --detach-sign --local-user "$GPG_KEY" \
        "$FILE"
}

function maybe_gpg_sign
{
    [[ -e "$1" ]] && gpg_sign "$1"
}

function command_exists
{
    type "$1" &>/dev/null
}

function find_archiver
{
    command_exists "$1" && echo "$1" || echo ':'
}

GIT_URL="$1"
if [[ -z "$GIT_URL" ]] ; then
    usage
    exit 1
fi

GIT_BRANCH="$2"
if [[ -z "$GIT_BRANCH" ]] ; then
    usage
    exit 1
fi

if [[ -z "$3" ]] ; then
    SRC_DIR=$GIT_BRANCH
else
    SRC_DIR="$3"
fi

if [[ ! -z "$4" ]] ; then
    GPG_KEY="$4"
else
    GPG_KEY=
fi

DEST_DIR="$PWD"

TMPDIR=${TMPDIR:-${TMP:-${TEMP}}}
if [[ -z "${TMPDIR}" ]] ; then
    unset TMPDIR
else
    export TMPDIR
fi
TMP_DIR=`mktemp -d -t log4cplus.XXXXXXX`
pushd "$TMP_DIR"

TAR=${TAR:-$(find_archiver tar)}
XZ=${XZ:-$(find_archiver xz)}
BZIP2=${BZIP2:-$(find_archiver bzip2)}
GZIP=${GZIP:-$(find_archiver gzip)}
SEVENZA=${SEVENZA:-$(find_archiver 7za)}
LRZIP=${LRZIP:-$(find_archiver lrzip)}
GIT=${GIT:-git}
GPG=${GPG:-gpg}

$GIT clone -v --depth=1 "$GIT_URL" "$SRC_DIR"
(cd "$SRC_DIR" && $GIT rev-parse >REVISION)
rm -rf "$SRC_DIR/.git"

pushd "$SRC_DIR"
$SHELL ./scripts/fix-timestamps.sh
popd
{'fraction_non_alphanumeric': 0.207913918778202, 'fraction_numerical': 0.013536966331135023, 'mean_word_length': 3.716857610474632, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6253126', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1349, 'n_words': 251}