File: t-multiple-remotes.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 (192 lines) | stat: -rwxr-xr-x 4,294 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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# Test lfs capability to download data when blobs are stored in different
# endpoints

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

# This feature depends on the treeish parameter that is provided as metadata
# in git versions higher or equal than 2.27
ensure_git_version_isnt $VERSION_LOWER "2.27.0"

reponame="$(basename "$0" ".sh")"

prepare_consumer() {
  local consumer="$1"
  mkdir "$consumer"
  cd "$consumer"
  git init
  git remote add mr "file://$(urlify "$REMOTEDIR/$smain.git")"
  git remote add fr "file://$(urlify "$REMOTEDIR/$sfork.git")"
  git fetch mr
  git fetch fr
}

prepare_forks () {
  local testcase="$1"
  smain="$reponame"-"$testcase"-main-remote
  sfork="$reponame"-"$testcase"-fork-remote
  cmain="$HOME"/"$reponame"-"$testcase"-main-repo
  cfork="$HOME"/"$reponame"-"$testcase"-fork-repo
  setup_remote_repo "$smain"
  setup_remote_repo "$sfork"
  prepare_consumer "$cmain"
  git checkout -b main
  git lfs track '*.bin'
  git add --all
  git commit -m "Initial commit"
  git push -u mr main
  git push -u fr main
  #Add a .bin in main repo
  touch a.bin
  printf "1234" > a.bin
  git add --all
  git commit -m "Add Bin file"
  git push mr main
  prepare_consumer "$cfork"
}

exec_fail_git(){
  set +e
  git "$@"
  res=$?
  set -e
  if [ "$res" = "0" ]; then
    exit 1
  fi
}

begin_test "accept reset to different remote"
(
  set -e
  prepare_forks "a-reset"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect true
  git reset --hard mr/main
)
end_test

begin_test "accept pull from different remote"
(
  set -e
  prepare_forks "a-pull"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect true
  git pull mr main
)
end_test

begin_test "accept checkout different remote"
(
  set -e
  prepare_forks "a-checkout"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect true
  git checkout mr/main
)
end_test

begin_test "accept rebase different remote"
(
  set -e
  prepare_forks "a-rebase"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect true
  git rebase mr/main
)
end_test

begin_test "accept add bin file with sparsecheckout"
(
  set -e
  prepare_forks "a-sparsecheckout"
  git sparse-checkout init --no-cone
  git sparse-checkout set /.gitignore
  git checkout mr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect true
  git sparse-checkout add a.bin
)
end_test

begin_test "accept cherry-pick head different remote"
(
  set -e
  prepare_forks "a-cherrypick"
  git checkout -b main --track fr/main
  git config lfs.remote.searchall true
  git config lfs.remote.autodetect false
  git cherry-pick mr/main
)
end_test

begin_test "reject reset to different remote"
(
  set -e
  prepare_forks "r-reset"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git reset --hard mr/main
)
end_test

begin_test "reject pull from different remote"
(
  set -e
  prepare_forks "r-pull"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git pull mr main
)
end_test

begin_test "reject checkout different remote"
(
  set -e
  prepare_forks "r-checkout"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git checkout mr/main
)
end_test

begin_test "reject rebase different remote"
(
  set -e
  prepare_forks "r-rebase"
  git checkout fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git rebase mr/main
)
end_test

begin_test "reject add bin file with sparsecheckout"
(
  set -e
  prepare_forks "r-sparsecheckout"
  git sparse-checkout init --no-cone
  git sparse-checkout set /.gitignore
  git checkout mr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git sparse-checkout add a.bin
)
end_test

begin_test "reject cherry-pick head different remote"
(
  set -e
  prepare_forks "r-cherrypick"
  git checkout -b main --track fr/main
  git config lfs.remote.searchall false
  git config lfs.remote.autodetect false
  exec_fail_git cherry-pick mr/main
)
end_test