File: t-clean.sh

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (89 lines) | stat: -rwxr-xr-x 3,237 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash

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

clean_setup () {
  mkdir "$1"
  cd "$1"
  git init
}

begin_test "clean simple file"
(
  set -e
  clean_setup "simple"

  echo "whatever" | git lfs clean | tee clean.log
  [ "$(pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9)" = "$(cat clean.log)" ]
)
end_test

begin_test "clean a pointer"
(
  set -e
  clean_setup "pointer"

  pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9 | git lfs clean | tee clean.log
  [ "$(pointer cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411 9)" = "$(cat clean.log)" ]
)
end_test

begin_test "clean pseudo pointer"
(
  set -e
  clean_setup "pseudo"

  echo "version https://git-lfs.github.com/spec/v1
oid sha256:7cd8be1d2cd0dd22cd9d229bb6b5785009a05e8b39d405615d882caac56562b5
size 1024

This is my test pointer.  There are many like it, but this one is mine." | git lfs clean | tee clean.log
  [ "$(pointer f492acbebb5faa22da4c1501c022af035469f624f426631f31936575873fefe1 202)" = "$(cat clean.log)" ]
)
end_test

begin_test "clean pseudo pointer with extra data"
(
  set -e
  clean_setup "extra-data"

  # pointer includes enough extra data to fill the 'git lfs clean' buffer
  printf "version https://git-lfs.github.com/spec/v1
oid sha256:7cd8be1d2cd0dd22cd9d229bb6b5785009a05e8b39d405615d882caac56562b5
size 1024
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
This is my test pointer.  There are many like it, but this one is mine.\n" | git lfs clean | tee clean.log
  [ "$(pointer c2f909f6961bf85a92e2942ef3ed80c938a3d0ebaee6e72940692581052333be 586)" = "$(cat clean.log)" ]
)
end_test

begin_test "clean stdin"
(
  set -e

  # git-lfs-clean(1) writes to .git/lfs/objects, and therefore must be executed
  # within a repository.
  reponame="clean-over-stdin"
  git init "$reponame"
  cd "$reponame"

  lfstest-genrandom --base64 1024 >small.dat
  lfstest-genrandom --base64 2048 >large.dat

  expected_small="$(calc_oid_file "small.dat")"
  expected_large="$(calc_oid_file "large.dat")"

  actual_small="$(git lfs clean < "small.dat" | grep "oid" | cut -d ':' -f 2)"
  actual_large="$(git lfs clean < "large.dat" | grep "oid" | cut -d ':' -f 2)"

  if [ "$expected_small" != "$actual_small" ]; then
    echo >&2 "fatal: expected small OID of: $expected_small, got: $actual_small"
    exit 1
  fi

  if [ "$expected_large" != "$actual_large" ]; then
    echo >&2 "fatal: expected large OID of: $expected_large, got: $actual_large"
    exit 1
  fi
)
end_test