-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.sh
More file actions
executable file
·113 lines (92 loc) · 2.25 KB
/
example.sh
File metadata and controls
executable file
·113 lines (92 loc) · 2.25 KB
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
#!/bin/bash
# Example workflow demonstrating MVCS functionality
set -e
echo "=== MVCS Example Workflow ==="
echo
# Save the mvcs directory
MVCS_DIR="$(pwd)"
MVCS_BIN="$MVCS_DIR/mvcs"
# Build MVCS
echo "Step 1: Building MVCS..."
make clean && make
if [ $? -ne 0 ]; then
echo "Build failed!"
exit 1
fi
echo
# Create a test directory
echo "Step 2: Creating test directory..."
rm -rf /tmp/mvcs-demo
mkdir -p /tmp/mvcs-demo
cd /tmp/mvcs-demo
echo
# Initialize repository
echo "Step 3: Initializing repository..."
$MVCS_BIN init
echo
# Create some files
echo "Step 4: Creating files..."
echo "This is the README file." > README.md
echo "print('Hello, World!')" > hello.py
echo "int main() { return 0; }" > main.c
ls -l
echo
# Add files to staging
echo "Step 5: Adding files to staging area..."
export MVCS_AUTHOR="John Doe <john@example.com>"
$MVCS_BIN add README.md
$MVCS_BIN add hello.py
$MVCS_BIN add main.c
echo
# Check index
echo "Step 6: Checking staging area (index file)..."
cat .mvcs/index
echo
# Create first commit
echo "Step 7: Creating first commit..."
$MVCS_BIN commit "Initial commit with project files"
echo
# Modify a file
echo "Step 8: Modifying a file..."
echo "print('Hello, MVCS!')" > hello.py
echo
# Stage the change
echo "Step 9: Staging the modification..."
$MVCS_BIN add hello.py
echo
# Create second commit
echo "Step 10: Creating second commit..."
export MVCS_AUTHOR="Jane Smith <jane@example.com>"
$MVCS_BIN commit "Update hello.py with MVCS greeting"
echo
# View commit history
echo "Step 11: Viewing commit history..."
$MVCS_BIN log
echo
# Inspect objects
echo "Step 12: Inspecting objects..."
echo
# Get hash of hello.py
HASH=$($MVCS_BIN hash-object hello.py)
echo "Hash of hello.py: $HASH"
echo
# View the blob
echo "Blob content:"
$MVCS_BIN cat-file $HASH
echo
# Get first commit hash (from log output)
echo "Step 13: Viewing commit and tree objects..."
# Find the second (first) commit hash from refs
if [ -f .mvcs/refs/heads/master ]; then
CURRENT_COMMIT=$(cat .mvcs/refs/heads/master)
echo "Current commit: $CURRENT_COMMIT"
echo
echo "Commit object:"
$MVCS_BIN cat-file $CURRENT_COMMIT
echo
fi
echo "Step 14: Repository structure..."
echo "Directory tree:"
find .mvcs -type f | sort
echo
echo "=== Demo Complete ==="