Skip to content

Commit 75393da

Browse files
committed
test: new test script cronjob-mirror-pull.txtar
1 parent 2dd2780 commit 75393da

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

testscript/script_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ Host *
313313
ServerAliveInterval 60
314314
`
315315

316+
const GIT_DATE = "2026-03-29T00:00:00Z"
317+
316318
func cmdGit(key string) func(ts *testscript.TestScript, neg bool, args []string) {
317319
return func(ts *testscript.TestScript, neg bool, args []string) {
318320
ts.Check(os.WriteFile(
@@ -330,6 +332,11 @@ func cmdGit(key string) func(ts *testscript.TestScript, neg bool, args []string)
330332
)
331333
// Disable git prompting for credentials.
332334
ts.Setenv("GIT_TERMINAL_PROMPT", "0")
335+
336+
// Keep the same git commit hash in an empty repository
337+
ts.Setenv("GIT_AUTHOR_DATE", GIT_DATE)
338+
ts.Setenv("GIT_COMMITTER_DATE", GIT_DATE)
339+
333340
args = append([]string{
334341
"-c", "user.email=john@example.com",
335342
"-c", "user.name=John Doe",
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# vi: set ft=conf
2+
3+
# start soft serve
4+
exec soft serve &
5+
# wait for SSH server to start
6+
ensureserverrunning SSH_PORT
7+
8+
# create a repo
9+
soft repo create repo1
10+
11+
# clone repo
12+
git clone ssh://localhost:$SSH_PORT/repo1 repo1
13+
14+
# create some files, commits, tags...
15+
mkfile ./repo1/README.md '# Hello in first commit'
16+
git -C repo1 add -A
17+
git -C repo1 commit -m 'first commit'
18+
git -C repo1 push origin HEAD
19+
soft repo commit repo1 3565323
20+
cmp stdout first_commit.txt
21+
22+
# overwrite the first commit
23+
mkfile ./repo1/README.md '# Hello in second commit'
24+
git -C repo1 add -A
25+
git -C repo1 commit --amend -m 'second commit'
26+
git -C repo1 push --force origin HEAD
27+
# the first commit still exists
28+
soft repo commit repo1 3565323
29+
cmp stdout first_commit.txt
30+
31+
# clean up
32+
soft cronjob git-gc --config gc.reflogExpire=now --config gc.pruneExpire=now
33+
! soft repo commit repo1 3565323
34+
stderr 'Error: revision does not exist'
35+
36+
-- first_commit.txt --
37+
commit 3565323
38+
Author: John Doe
39+
Date: Sun Mar 29 00:00:00 UTC 2026
40+
first commit
41+
42+
43+
README.md | 1 +
44+
1 file changed, 1 insertion(+)
45+
46+
diff --git a/README.md b/README.md
47+
new file mode 100644
48+
index 0000000000000000000000000000000000000000..e01a0969efececc7f96e77f41cf754aab78f7669
49+
--- /dev/null
50+
+++ b/README.md
51+
@@ -0,0 +1 @@
52+
+# Hello in first commit
53+

0 commit comments

Comments
 (0)