<commit_before>#!/bin/bash
#
# Copyright 2015 The Bazel 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.

set -eu

# This is a generated file that loads all docker layers built by "docker_build".

RUNFILES="${PYTHON_RUNFILES:-${BASH_SOURCE[0]}.runfiles}"

DOCKER="${DOCKER:-docker}"

FULL_DOCKER_VERSION=$(docker version -f {{.Server.Version}} 2> /dev/null \
    || echo "1.5.0")
DOCKER_MAJOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $1 }')
DOCKER_MINOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $2 }')
if [ "$DOCKER_MAJOR_VERSION" -eq "1" ] && [ "$DOCKER_MINOR_VERSION" -lt "10" ]; then
  LEGACY_DOCKER=true
else
  LEGACY_DOCKER=false
fi

# List all images identifier (only the identifier) from the local
# docker registry.
IMAGES="$("${DOCKER}" images -aq)"
IMAGE_LEN=$(for i in $IMAGES; do echo -n $i | wc -c; done | sort -g | head -1 | xargs)

[ -n "$IMAGE_LEN" ] || IMAGE_LEN=64

function incr_load() {
  # Load a layer if and only if the layer is not in "$IMAGES", that is
  # in the local docker registry.
  if [ "$LEGACY_DOCKER" = true ]; then
    name=$(cat ${RUNFILES}/$1)
  else
    name=$(cat ${RUNFILES}/$2)
  fi

  if (echo "$IMAGES" | grep -q ^${name:0:$IMAGE_LEN}$); then
    echo "Skipping $name, already loaded."
  else
    echo "Loading $name..."
    "${DOCKER}" load -i ${RUNFILES}/$3
  fi
}

function tag_layer() {
  if [ "$LEGACY_DOCKER" = true ]; then
    name=$(cat ${RUNFILES}/$2)
  else
    name=$(cat ${RUNFILES}/$3)
  fi

  TAG="$1"
  echo "Tagging ${name} as ${TAG}"
  if [ "$LEGACY_DOCKER" = true ]; then
    "${DOCKER}" tag -f ${name} ${TAG}
  else
    "${DOCKER}" tag ${name} ${TAG}
  fi
}

# List of 'incr_load' statements for all layers.
# This generated and injected by docker_build.
%{load_statements}

# List of 'tag_layer' statements for all tags.
# This generated and injected by docker_build.
%{tag_statements}
<commit_msg>Use sha256 prefix when tagging docker images with full IDs<commit_after>#!/bin/bash
#
# Copyright 2015 The Bazel 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.

set -eu

# This is a generated file that loads all docker layers built by "docker_build".

RUNFILES="${PYTHON_RUNFILES:-${BASH_SOURCE[0]}.runfiles}"

DOCKER="${DOCKER:-docker}"

FULL_DOCKER_VERSION=$(docker version -f {{.Server.Version}} 2> /dev/null \
    || echo "1.5.0")
DOCKER_MAJOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $1 }')
DOCKER_MINOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $2 }')
if [ "$DOCKER_MAJOR_VERSION" -eq "1" ] && [ "$DOCKER_MINOR_VERSION" -lt "10" ]; then
  LEGACY_DOCKER=true
else
  LEGACY_DOCKER=false
fi

# List all images identifier (only the identifier) from the local
# docker registry.
IMAGES="$("${DOCKER}" images -aq)"
IMAGE_LEN=$(for i in $IMAGES; do echo -n $i | wc -c; done | sort -g | head -1 | xargs)

[ -n "$IMAGE_LEN" ] || IMAGE_LEN=64

function incr_load() {
  # Load a layer if and only if the layer is not in "$IMAGES", that is
  # in the local docker registry.
  if [ "$LEGACY_DOCKER" = true ]; then
    name=$(cat ${RUNFILES}/$1)
  else
    name=$(cat ${RUNFILES}/$2)
  fi

  if (echo "$IMAGES" | grep -q ^${name:0:$IMAGE_LEN}$); then
    echo "Skipping $name, already loaded."
  else
    echo "Loading $name..."
    "${DOCKER}" load -i ${RUNFILES}/$3
  fi
}

function tag_layer() {
  if [ "$LEGACY_DOCKER" = true ]; then
    name=$(cat ${RUNFILES}/$2)
  else
    name=$(cat ${RUNFILES}/$3)
  fi

  TAG="$1"
  echo "Tagging ${name} as ${TAG}"
  if [ "$LEGACY_DOCKER" = true ]; then
    "${DOCKER}" tag -f ${name} ${TAG}
  else
    "${DOCKER}" tag sha256:${name} ${TAG}
  fi
}

# List of 'incr_load' statements for all layers.
# This generated and injected by docker_build.
%{load_statements}

# List of 'tag_layer' statements for all tags.
# This generated and injected by docker_build.
%{tag_statements}

{'fraction_non_alphanumeric': 0.14440359477124182, 'fraction_numerical': 0.012663398692810458, 'mean_word_length': 3.906813627254509, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '6431997', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1677, 'n_words': 577}