git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob a4b11495c68beee4552935fef9a25be1e6e44048 6455 bytes (raw)
name: t/t5517-push-mirror.sh 	 # note: path name is non-authoritative(*)

  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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
 
#!/bin/sh

test_description='pushing to a mirror repository'

. ./test-lib.sh

D=$(pwd)

invert () {
	if "$@"; then
		return 1
	else
		return 0
	fi
}

mk_repo_pair () {
	rm -rf main mirror &&
	mkdir mirror &&
	(
		cd mirror &&
		git init &&
		git config receive.denyCurrentBranch warn
	) &&
	mkdir main &&
	(
		cd main &&
		git init &&
		git remote add $1 up ../mirror
	)
}


# BRANCH tests
test_expect_success 'push mirror creates new branches' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/heads/main) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror updates existing branches' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git push --mirror up &&
		echo two >foo && git add foo && git commit -m two &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/heads/main) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror force updates existing branches' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git push --mirror up &&
		echo two >foo && git add foo && git commit -m two &&
		git push --mirror up &&
		git reset --hard HEAD^ &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/heads/main) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror removes branches' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git branch remove main &&
		git push --mirror up &&
		git branch -D remove &&
		git push --mirror up
	) &&
	(
		cd mirror &&
		invert git show-ref -s --verify refs/heads/remove
	)

'

test_expect_success 'push mirror adds, updates and removes branches together' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git branch remove main &&
		git push --mirror up &&
		git branch -D remove &&
		git branch add main &&
		echo two >foo && git add foo && git commit -m two &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/heads/main) &&
	main_add=$(cd main && git show-ref -s --verify refs/heads/add) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/heads/main) &&
	mirror_add=$(cd mirror && git show-ref -s --verify refs/heads/add) &&
	test "$main_main" = "$mirror_main" &&
	test "$main_add" = "$mirror_add" &&
	(
		cd mirror &&
		invert git show-ref -s --verify refs/heads/remove
	)

'


# TAG tests
test_expect_success 'push mirror creates new tags' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git tag -f tmain main &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror updates existing tags' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git tag -f tmain main &&
		git push --mirror up &&
		echo two >foo && git add foo && git commit -m two &&
		git tag -f tmain main &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror force updates existing tags' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git tag -f tmain main &&
		git push --mirror up &&
		echo two >foo && git add foo && git commit -m two &&
		git tag -f tmain main &&
		git push --mirror up &&
		git reset --hard HEAD^ &&
		git tag -f tmain main &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) &&
	test "$main_main" = "$mirror_main"

'

test_expect_success 'push mirror removes tags' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git tag -f tremove main &&
		git push --mirror up &&
		git tag -d tremove &&
		git push --mirror up
	) &&
	(
		cd mirror &&
		invert git show-ref -s --verify refs/tags/tremove
	)

'

test_expect_success 'push mirror adds, updates and removes tags together' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git tag -f tmain main &&
		git tag -f tremove main &&
		git push --mirror up &&
		git tag -d tremove &&
		git tag tadd main &&
		echo two >foo && git add foo && git commit -m two &&
		git tag -f tmain main &&
		git push --mirror up
	) &&
	main_main=$(cd main && git show-ref -s --verify refs/tags/tmain) &&
	main_add=$(cd main && git show-ref -s --verify refs/tags/tadd) &&
	mirror_main=$(cd mirror && git show-ref -s --verify refs/tags/tmain) &&
	mirror_add=$(cd mirror && git show-ref -s --verify refs/tags/tadd) &&
	test "$main_main" = "$mirror_main" &&
	test "$main_add" = "$mirror_add" &&
	(
		cd mirror &&
		invert git show-ref -s --verify refs/tags/tremove
	)

'

test_expect_success 'remote.foo.mirror adds and removes branches' '

	mk_repo_pair --mirror &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git branch keep main &&
		git branch remove main &&
		git push up &&
		git branch -D remove &&
		git push up
	) &&
	(
		cd mirror &&
		git show-ref -s --verify refs/heads/keep &&
		invert git show-ref -s --verify refs/heads/remove
	)

'

test_expect_success 'remote.foo.mirror=no has no effect' '

	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git config --add remote.up.mirror no &&
		git branch keep main &&
		git push --mirror up &&
		git branch -D keep &&
		git push up :
	) &&
	(
		cd mirror &&
		git show-ref -s --verify refs/heads/keep
	)

'

test_expect_success 'push to mirrored repository with refspec fails' '
	mk_repo_pair &&
	(
		cd main &&
		echo one >foo && git add foo && git commit -m one &&
		git config --add remote.up.mirror true &&
		test_must_fail git push up main
	)
'

test_done

debug log:

solving a4b11495c6 ...
found a4b11495c6 in https://public-inbox.org/git/727de6fdf5f2eb0765d26c18a7960c5770a51a1d.1605221039.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/b7333ef2012b2bdfc03054c8ad2cc7222cb6aaae.1605629548.git.gitgitgadget@gmail.com/
found e4edd56404 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 e4edd56404fe636600e3f32eef754c7fb4b6b639	t/t5517-push-mirror.sh

applying [1/1] https://public-inbox.org/git/727de6fdf5f2eb0765d26c18a7960c5770a51a1d.1605221039.git.gitgitgadget@gmail.com/
diff --git a/t/t5517-push-mirror.sh b/t/t5517-push-mirror.sh
index e4edd56404..a4b11495c6 100755

Checking patch t/t5517-push-mirror.sh...
Applied patch t/t5517-push-mirror.sh cleanly.

skipping https://public-inbox.org/git/b7333ef2012b2bdfc03054c8ad2cc7222cb6aaae.1605629548.git.gitgitgadget@gmail.com/ for a4b11495c6
index at:
100755 a4b11495c68beee4552935fef9a25be1e6e44048	t/t5517-push-mirror.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).