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

. "$(dirname "$0")/testlib.sh"

begin_test "content-type: is enabled by default"
(
  set -e

  reponame="content-type-enabled-default"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.zip"
  printf "aaaaaaaaaa" > a.txt
  zip -j a.zip a.txt
  rm a.txt

  git add .gitattributes a.zip
  git commit -m "initial commit"
  GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log

  [ 1 -eq "$(grep -c "Content-Type: application/zip" push.log)" ]
)
end_test

begin_test "content-type: is disabled by configuration"
(
  set -e

  reponame="content-type-disabled-by-configuration"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.zip"
  printf "aaaaaaaaaa" > a.txt
  zip -j a.zip a.txt
  rm a.txt

  git add .gitattributes a.zip
  git commit -m "initial commit"
  git config "lfs.$GITSERVER/$reponame.git.contenttype" 0
  GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log

  [ 1 -eq "$(grep -c "Content-Type: application/zip" push.log)" ]
)
end_test

begin_test "content-type: warning message"
(
  set -e

  reponame="content-type-warning-message"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.txt"<commit_msg>t: fix 'git config' invocation in content type tests<commit_after>#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

begin_test "content-type: is enabled by default"
(
  set -e

  reponame="content-type-enabled-default"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.zip"
  printf "aaaaaaaaaa" > a.txt
  zip -j a.zip a.txt
  rm a.txt

  git add .gitattributes a.zip
  git commit -m "initial commit"
  GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log

  [ 1 -eq "$(grep -c "Content-Type: application/zip" push.log)" ]
)
end_test

begin_test "content-type: is disabled by configuration"
(
  set -e

  reponame="content-type-disabled-by-configuration"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.zip"
  printf "aaaaaaaaaa" > a.txt
  zip -j a.zip a.txt
  rm a.txt

  git add .gitattributes a.zip
  git commit -m "initial commit"
  git config "lfs.$GITSERVER.contenttype" 0
  GIT_CURL_VERBOSE=1 git push origin master 2>&1 | tee push.log

  [ 0 -eq "$(grep -c "Content-Type: application/zip" push.log)" ]
)
end_test

begin_test "content-type: warning message"
(
  set -e

  reponame="content-type-warning-message"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" "$reponame"

  git lfs track "*.txt"
{'fraction_non_alphanumeric': 0.13240418118466898, 'fraction_numerical': 0.007742934572202865, 'mean_word_length': 3.689655172413793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '5858970', 'n_tokens_mistral': 1009, 'n_tokens_neox': 963, 'n_words': 263}