-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_branches.sh
executable file
·47 lines (35 loc) · 1.15 KB
/
test_branches.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
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status.
echo "Initializing repository..."
rm -rf test_repo
mkdir test_repo
cd test_repo
../mini-git init
echo "Creating file on master branch..."
echo "Content on master branch" > test.txt
../mini-git add test.txt
../mini-git commit "Add test.txt on master"
echo "Creating and switching to feature branch..."
../mini-git branch feature
../mini-git checkout feature
echo "Modifying file on feature branch..."
echo "Content on feature branch" > test.txt
../mini-git add test.txt
../mini-git commit "Modify test.txt on feature"
echo "Switching back to master branch..."
../mini-git checkout master
echo "Content on master branch:"
cat test.txt
if [ "$(cat test.txt)" != "Content on master branch" ]; then
echo "Test failed: Unexpected content on master branch"
exit 1
fi
echo "Switching to feature branch..."
../mini-git checkout feature
echo "Content on feature branch:"
cat test.txt
if [ "$(cat test.txt)" != "Content on feature branch" ]; then
echo "Test failed: Unexpected content on feature branch"
exit 1
fi
echo "Test passed: File contents changed correctly between branches"