Debian Codegraph @

t/t-umask.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . "$(dirnamescip-shell system . . dirname. "$0")/testlib.sh"
4
5 if [scip-shell system . . `[`. $IS_WINDOWS -eq 1 ]; then
6 echoscip-shell system . . echo. "skip $0: Windows lacks POSIX permissions"
7 exit
8 fi
9
10 clean_setupscip-shell shell shell-project 0.0.0 clean_setup(). () {
11 mkdirscip-shell system . . mkdir. "$1"
12 cd "$1"
13 gitscip-shell system . . git. init
14 }
15
16 perms_forscip-shell shell shell-project 0.0.0 perms_for(). () {
17 local file=$(echoscip-shell system . . echo. "$1" | sedscip-shell system . . sed. "s!^\(..\)\(..\)!.git/lfs/objects/\1/\2/\1\2!")
18 local perms=$(lsscip-shell system . . ls. -l "$file" | awkscip-shell system . . awk. '{print $1}')
19 # Trim extended attributes:
20 echoscip-shell system . . echo. ${perms:0:10}
21 }
22
23 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). () {
24 local perms="$1"
25 [scip-shell system . . `[`. 0 -eq "$(findscip-shell system . . find. .git/lfs -type d -ls | grepscip-shell system . . grep. -c -vE "$perms")" ]
26 }
27
28 begin_test "honors umask"
29 (
30 set -e
31 clean_setupscip-shell shell shell-project 0.0.0 clean_setup(). "simple"
32
33 umask 027
34 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
35 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411)" = "-rw-r-----" ]
36
37 umask 007
38 echoscip-shell system . . echo. "random" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
39 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). 87c1b129fbadd7b6e9abc0a9ef7695436d767aece042bec198a97e949fcbe14c)" = "-rw-rw----" ]
40 )
41 end_test
42
43 begin_test "honors umask for directories"
44 (
45 set -e
46 reponame="simple-directories"
47 setup_remote_repo_with_file "$reponame" "a.dat"
48
49 umask 027
50 clone_repo "$reponame" "$reponame-a"
51 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
52 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxr-[xs]---"
53
54 umask 007
55 clone_repo "$reponame" "$reponame-b"
56 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
57 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxrw[xs]---"
58 )
59 end_test
60
61 # This is tested more comprehensively in the unit tests.
62 begin_test "honors core.sharedrepository"
63 (
64 set -e
65 clean_setupscip-shell shell shell-project 0.0.0 clean_setup(). "shared-repo"
66
67 umask 027
68 gitscip-shell system . . git. config core.sharedRepository 0660
69 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
70 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411)" = "-rw-rw----" ]
71
72 gitscip-shell system . . git. config core.sharedRepository everybody
73 echoscip-shell system . . echo. "random" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
74 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). 87c1b129fbadd7b6e9abc0a9ef7695436d767aece042bec198a97e949fcbe14c)" = "-rw-rw-r--" ]
75
76 gitscip-shell system . . git. config core.sharedRepository false
77 echoscip-shell system . . echo. "something else" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
78 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). a1621be95040239ee14362c16e20510ddc20f527d772d823b2a1679b33f5cd74)" = "-rw-r-----" ]
79
80 umask 007
81 echoscip-shell system . . echo. "who cares" | gitscip-shell system . . git. lfs clean | teescip-shell system . . tee. clean.log
82 [scip-shell system . . `[`. "$(perms_forscip-shell shell shell-project 0.0.0 perms_for(). 261ded5f01a8ca18d9fb1958e8f58c53fa77648cc88a6d67c93d241a91133f3e)" = "-rw-rw----" ]
83
84 )
85 end_test
86
87 begin_test "honors core.sharedrepository for directories"
88 (
89 set -e
90 reponame="shared-repo-directories"
91 setup_remote_repo_with_file "$reponame" "a.dat"
92
93 umask 027
94 gitscip-shell system . . git. config --global core.sharedRepository 0660
95 clone_repo "$reponame" "$reponame-a"
96 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
97 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxrw[xs]---"
98
99 gitscip-shell system . . git. config --global core.sharedRepository everybody
100 clone_repo "$reponame" "$reponame-b"
101 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
102 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxrw[xs]r-x"
103
104 gitscip-shell system . . git. config --global core.sharedRepository false
105 clone_repo "$reponame" "$reponame-c"
106 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
107 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxr-[xs]---"
108
109 umask 007
110 clone_repo "$reponame" "$reponame-d"
111 echoscip-shell system . . echo. "whatever" | gitscip-shell system . . git. lfs clean
112 assert_dir_permsscip-shell shell shell-project 0.0.0 assert_dir_perms(). "drwxrw[xs]---"
113
114 gitscip-shell system . . git. config --global --unset-all core.sharedRepository
115 )
116 end_test