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

. "test/testlib.sh"

begin_test "creating a lock"
(
  set -e

  reponame="lock_create_simple"
  setup_remote_repo_with_file "$reponame" "a.dat"

  GITLFSLOCKSENABLED=1 git lfs lock "a.dat" | tee lock.log
  grep "'a.dat' was locked" lock.log

  id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "create lock with server using client cert"
(
  set -e
  reponame="lock_create_client_cert"
  setup_remote_repo_with_file "$reponame" "a.dat"

  git config lfs.url "$CLIENTCERTGITSERVER/$reponame.git/info/lfs"
  GITLFSLOCKSENABLED=1 git lfs lock "a.dat" | tee lock.log
  grep "'a.dat' was locked" lock.log

  id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "creating a lock (--json)"
(
  set -e

  reponame="lock_create_simple_json"
  setup_remote_repo_with_file "$reponame" "a_json.dat"

  GITLFSLOCKSENABLED=1 git lfs lock --json "a_json.dat" | tee lock.log
  grep "\"path\":\"a_json.dat\"" lock.log

  id=$(grep -o "\"id\":\".*\"" lock.log | cut -d \" -f 4)
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "locking a previously locked file"
(
  set -e<commit_msg>change file name<commit_after>#!/usr/bin/env bash

. "test/testlib.sh"

begin_test "creating a lock"
(
  set -e

  reponame="lock_create_simple"
  setup_remote_repo_with_file "$reponame" "a.dat"

  GITLFSLOCKSENABLED=1 git lfs lock "a.dat" | tee lock.log
  grep "'a.dat' was locked" lock.log

  id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "create lock with server using client cert"
(
  set -e
  reponame="lock_create_client_cert"
  setup_remote_repo_with_file "$reponame" "cc.dat"

  git config lfs.url "$CLIENTCERTGITSERVER/$reponame.git/info/lfs"
  GITLFSLOCKSENABLED=1 git lfs lock "cc.dat" | tee lock.log
  grep "'cc.dat' was locked" lock.log

  id=$(grep -oh "\((.*)\)" lock.log | tr -d "()")
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "creating a lock (--json)"
(
  set -e

  reponame="lock_create_simple_json"
  setup_remote_repo_with_file "$reponame" "a_json.dat"

  GITLFSLOCKSENABLED=1 git lfs lock --json "a_json.dat" | tee lock.log
  grep "\"path\":\"a_json.dat\"" lock.log

  id=$(grep -o "\"id\":\".*\"" lock.log | cut -d \" -f 4)
  assert_server_lock "$reponame" "$id"
)
end_test

begin_test "locking a previously locked file"
(
  set -e
{'fraction_non_alphanumeric': 0.16437246963562754, 'fraction_numerical': 0.0032388663967611335, 'mean_word_length': 3.873767258382643, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6769090', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1022, 'n_words': 231}