-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathwyag-tests.sh
executable file
·202 lines (178 loc) · 4.92 KB
/
wyag-tests.sh
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
#!/usr/bin/env bash
set -e
function step() {
pos=$(caller)
echo $pos $@
}
wyag=$(realpath ./wyag)
testdir=/tmp/wyag-tests
if [[ -e $testdir ]]; then
rm -rf $testdir/*
else
mkdir $testdir
fi
cd $testdir
step "working on $(pwd)"
step Create repos
$wyag init left
git init right > /dev/null
step status
cd left
git status > /dev/null
cd ../right
git status > /dev/null
cd ..
step hash-object
echo "Don't read me" > README
$wyag hash-object README > hash1
git hash-object README > hash2
cmp --quiet hash1 hash2
step hash-object -w
cd left
$wyag hash-object -w ../README > /dev/null
cd ../right
git hash-object -w ../README > /dev/null
cd ..
ls left/.git/objects/b1/7df541639ec7814a9ad274e177d9f8da1eb951 > /dev/null
ls right/.git/objects/b1/7df541639ec7814a9ad274e177d9f8da1eb951 > /dev/null
step cat-file
cd left
$wyag cat-file blob b17d > ../file1
cd ../right
git cat-file blob b17d > ../file2
cd ..
cmp file1 file2
step cat-file with long hash
cd left
$wyag cat-file blob b17df541639ec7814a9ad274e177d9f8da1eb951 > ../file1
cd ../right
git cat-file blob b17df541639ec7814a9ad274e177d9f8da1eb951 > ../file2
cd ..
cmp file1 file2
step "Create commit (git only, nothing is tested)" #@FIXME Add wyag commit
cd left
echo "Aleph" > hebraic-letter.txt
git add hebraic-letter.txt
GIT_AUTHOR_DATE="2010-01-01 01:02:03 +0100" \
GIT_AUTHOR_NAME="wyag-tests.sh" \
GIT_AUTHOR_EMAIL="[email protected]" \
GIT_COMMITTER_DATE="2010-01-01 01:02:03 +0100" \
GIT_COMMITTER_NAME="wyag-tests.sh" \
GIT_COMMITTER_EMAIL="[email protected]" \
git commit --no-gpg-sign -m "Initial commit" > /dev/null
cd ../right
echo "Aleph" > hebraic-letter.txt
git add hebraic-letter.txt
GIT_AUTHOR_DATE="2010-01-01 01:02:03 +0100" \
GIT_AUTHOR_NAME="wyag-tests.sh" \
GIT_AUTHOR_EMAIL="[email protected]" \
GIT_COMMITTER_DATE="2010-01-01 01:02:03 +0100" \
GIT_COMMITTER_NAME="wyag-tests.sh" \
GIT_COMMITTER_EMAIL="[email protected]" \
git commit --no-gpg-sign -m "Initial commit" > /dev/null
cd ..
step cat-file on commit object without indirection
cd left
$wyag cat-file commit HEAD > ../file1
cd ../right
git cat-file commit HEAD > ../file2
cd ..
cmp file1 file2
step cat-file on tree object redirected from commit
cd left
$wyag cat-file tree HEAD > ../file1
cd ../right
git cat-file tree HEAD > ../file2
cd ..
cmp file1 file2
step "Add some directories and commits (git only, nothing is tested)" #@FIXME Add wyag commit
cd left
mkdir a
echo "Alpha" > a/greek_letters
mkdir b
echo "Hamza" > a/arabic_letters
git add a/*
GIT_AUTHOR_DATE="2010-01-01 01:02:03 +0100" \
GIT_AUTHOR_NAME="wyag-tests.sh" \
GIT_AUTHOR_EMAIL="[email protected]" \
GIT_COMMITTER_DATE="2010-01-01 01:02:03 +0100" \
GIT_COMMITTER_NAME="wyag-tests.sh" \
GIT_COMMITTER_EMAIL="[email protected]" \
git commit --no-gpg-sign -m "Commit 2" > /dev/null
cd ../right
mkdir a
echo "Alpha" > a/greek_letters
mkdir b
echo "Hamza" > a/arabic_letters
git add a/*
GIT_AUTHOR_DATE="2010-01-01 01:02:03 +0100" \
GIT_AUTHOR_NAME="wyag-tests.sh" \
GIT_AUTHOR_EMAIL="[email protected]" \
GIT_COMMITTER_DATE="2010-01-01 01:02:03 +0100" \
GIT_COMMITTER_NAME="wyag-tests.sh" \
GIT_COMMITTER_EMAIL="[email protected]" \
git commit --no-gpg-sign -m "Commit 2" > /dev/null
cd ..
step ls-tree
cd left
$wyag ls-tree HEAD > ../file1
cd ../right
git ls-tree HEAD > ../file2
cd ..
cmp file1 file2
step checkout
# Git and Wyag syntax are different here
cd left
$wyag checkout HEAD ../temp1
mkdir ../temp2
cd ../temp2
git --git-dir=../right/.git checkout .
cd ..
diff -r temp1 temp2
rm -rf temp1 temp2
step rev-parse
cd left
$wyag rev-parse HEAD > ../file1
$wyag rev-parse 75ee4 >> ../file1
$wyag rev-parse 8a617 >> ../file1
#@FIXME Tags missing, branches missing, remotes missing
cd ../right
git rev-parse HEAD > ../file2
git rev-parse 75ee4 >> ../file2
git rev-parse 8a617 >> ../file2
cd ..
cmp file1 file2
step "ls-files "
cd left
$wyag ls-files > ../file1
cd ../right
git ls-files > ../file2
cd ..
cmp file1 file2
gitignore_prepare() {
mkdir -p a/b/c/
echo "!*.txt" > a/b/c/.gitignore
echo "*.txt" > a/b/.gitignore
echo "*.org" > a/.gitignore
git add -A
}
step "gitignore"
cd left
gitignore_prepare
$wyag check-ignore a/b/c/hello.txt > ../file1
$wyag check-ignore a/b/hello.txt >> ../file1
$wyag check-ignore a/hello.org >> ../file1
$wyag check-ignore hello.org >> ../file1
cd ../right
set +e # git will return with non-zero
gitignore_prepare
git check-ignore a/b/c/hello.txt > ../file2
git check-ignore a/b/hello.txt >> ../file2
git check-ignore a/hello.org >> ../file2
git check-ignore hello.org >> ../file2
set -e
cd ..
cmp file1 file2
step THIS WAS A TRIUMPH
step "I'M MAKING A NOTE HERE"
step "HUGE SUCCESS"