-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathupdate-subverso.sh
More file actions
executable file
·99 lines (81 loc) · 3.64 KB
/
Copy pathupdate-subverso.sh
File metadata and controls
executable file
·99 lines (81 loc) · 3.64 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
#!/usr/bin/env bash
set -euo pipefail
# Extract subverso information from root manifest
ROOT_MANIFEST="./lake-manifest.json"
# Extract required fields for validation
SUBVERSO_REV=$(jq -r '.packages[] | select(.name == "subverso") | .rev' "$ROOT_MANIFEST")
SUBVERSO_URL=$(jq -r '.packages[] | select(.name == "subverso") | .url' "$ROOT_MANIFEST")
SUBVERSO_NOMODULE_REV=$(git ls-remote "$SUBVERSO_URL" "no-modules/$SUBVERSO_REV" | awk '{print $1}')
# Ensure we found subverso in the root manifest
if [ -z "$SUBVERSO_REV" ]; then
echo "Error: Could not find 'subverso' package in root manifest"
exit 1
fi
# Ensure we found subverso in the root manifest
if [ -z "$SUBVERSO_NOMODULE_REV" ]; then
echo "Error: Could not find no-module rev for SubVerso"
exit 1
fi
echo "Found subverso rev: $SUBVERSO_REV"
echo "Found subverso url: $SUBVERSO_URL"
echo "Found subverso non-module rev: $SUBVERSO_NOMODULE_REV"
# Find example lake-manifest.json files in the repo (excluding the root one)
find test-projects -name "lake-manifest.json" -not -path "$ROOT_MANIFEST" | grep -v "\.lake" | while read -r manifest_file; do
echo "Processing $manifest_file..."
# Check if the manifest contains subverso package
if jq -e '.packages[] | select(.name == "subverso")' "$manifest_file" > /dev/null; then
# Get actual values for comparison
ACTUAL_URL=$(jq -r '.packages[] | select(.name == "subverso") | .url' "$manifest_file")
ACTUAL_TYPE=$(jq -r '.packages[] | select(.name == "subverso") | .type' "$manifest_file")
ACTUAL_INPUT_REV=$(jq -r '.packages[] | select(.name == "subverso") | .inputRev' "$manifest_file")
# Validate URL
if [ "$ACTUAL_URL" != "$SUBVERSO_URL" ]; then
echo "Error in $manifest_file: URL mismatch"
echo " Expected: $SUBVERSO_URL"
echo " Actual: $ACTUAL_URL"
exit 1
fi
# Validate type
if [ "$ACTUAL_TYPE" != "git" ]; then
echo "Error in $manifest_file: Type mismatch"
echo " Expected: git"
echo " Actual: $ACTUAL_TYPE"
exit 1
fi
# Validate inputRev
if [ "$ACTUAL_INPUT_REV" != "main" ]; then
echo "Error in $manifest_file: InputRev mismatch"
echo " Expected: main"
echo " Actual: $ACTUAL_INPUT_REV"
exit 1
fi
# Projects that depend on Verso as a path dependency inherit its
# `module` status and need the modulized SubVerso rev. Other
# projects need the de-modulized rev.
# The directory containing this manifest's project
project_dir=$(dirname "$manifest_file")
if jq -e '.packages[] | select(.name == "verso" and .type == "path")' "$manifest_file" > /dev/null 2>&1; then
TARGET_REV="$SUBVERSO_REV"
echo " Uses Verso path dependency → modulized rev"
# Keep toolchain in sync with root
cp lean-toolchain "$project_dir/lean-toolchain"
echo " Copied lean-toolchain to $project_dir/"
else
TARGET_REV="$SUBVERSO_NOMODULE_REV"
echo " Standalone project → de-modulized rev"
fi
jq --arg rev "$TARGET_REV" '.packages = (.packages | map(
if .name == "subverso" then
.rev = $rev
else
.
end
))' "$manifest_file" > "${manifest_file}.tmp"
# Replace the original file
mv "${manifest_file}.tmp" "$manifest_file"
echo "Updated $manifest_file"
else
echo "No subverso package found in $manifest_file, skipping"
fi
done
echo "All manifests processed successfully"