File: t-tempfile.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 (34 lines) | stat: -rwxr-xr-x 785 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash

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

begin_test "cleans only temp files and directories older than an hour"
(
  set -e

  reponame="$(basename "$0" ".sh")"
  git init "$reponame"
  cd "$reponame"

  git lfs track '*.bin'
  echo foo > abc.bin
  git add abc.bin
  git commit -m 'Add abc.bin'

  tmpdir=.git/lfs/tmp
  mkdir -p "$tmpdir"

  mkdir "$tmpdir/dir-to-preserve"
  touch "$tmpdir/to-preserve"
  touch "$tmpdir/dir-to-preserve/file"
  # git format-patch datestamp; arbitrary timestamp in the past.
  TZ=UTC touch -t 200109170000.00 "$tmpdir/to-destroy"
  TZ=UTC touch -t 200109170000.00 "$tmpdir/dir-to-preserve/file"

  git lfs ls-files >/dev/null

  [ -f "$tmpdir/to-preserve" ]
  [ -f "$tmpdir/dir-to-preserve/file" ]
  [ ! -f "$tmpdir/to-destroy" ]
)
end_test