|
21 | 21 | # Change to repository root to ensure we're working from the correct directory |
22 | 22 | cd "$(git rev-parse --show-toplevel)" > /dev/null |
23 | 23 |
|
24 | | -# ===== WORKSPACE MANAGEMENT FUNCTIONS ===== |
25 | | - |
26 | | -# Get workspace directories from package.json workspaces configuration |
27 | | -# Returns list of workspace directories, falls back to all subdirectories if no workspaces config |
28 | | -get_workspace_dirs() { |
29 | | - if [ -f "package.json" ] && command -v jq > /dev/null 2>&1; then |
30 | | - # Try to get workspaces array from package.json |
31 | | - local workspaces=$(jq -r '.workspaces[]? // empty' package.json 2> /dev/null) |
32 | | - |
33 | | - if [ -n "$workspaces" ]; then |
34 | | - # Use configured workspaces |
35 | | - echo "$workspaces" | while read -r workspace_pattern; do |
36 | | - # Handle glob patterns by expanding them |
37 | | - if echo "$workspace_pattern" | grep -q '\*'; then |
38 | | - # Use find to expand glob patterns like "packages/*" |
39 | | - find . -path "./$workspace_pattern" -type d -mindepth 1 -maxdepth 2 2> /dev/null || true |
40 | | - else |
41 | | - # Direct path |
42 | | - if [ -d "$workspace_pattern" ]; then |
43 | | - echo "$workspace_pattern" |
44 | | - fi |
45 | | - fi |
46 | | - done |
47 | | - else |
48 | | - # Fallback to all subdirectories |
49 | | - find . -type d -mindepth 1 -maxdepth 1 |
50 | | - fi |
51 | | - else |
52 | | - # Fallback to all subdirectories when package.json or jq not available |
53 | | - find . -type d -mindepth 1 -maxdepth 1 |
54 | | - fi |
55 | | -} |
56 | | - |
57 | | -# Get affected workspace names from commit history for a given range |
58 | | -# Parameters: range (git range specification) |
59 | | -# Returns list of workspace names that have commits with matching scopes |
60 | | -get_affected_workspaces() { |
61 | | - local range="$1" |
62 | | - |
63 | | - # Extract scopes from commits and match against workspace names |
64 | | - git log --oneline --format="%s" "$range" 2> /dev/null \ |
65 | | - | sed -n 's/^[^(]*(\([^)]*\)):.*/\1/p' \ |
66 | | - | sort -u \ |
67 | | - | while read -r commit_scope; do |
68 | | - # Check if this scope matches any workspace directory |
69 | | - get_workspace_dirs | while read -r workspace_dir; do |
70 | | - local workspace_name=$(basename "$workspace_dir") |
71 | | - if [ "$commit_scope" = "$workspace_name" ]; then |
72 | | - echo "$workspace_dir" |
73 | | - fi |
74 | | - done |
75 | | - done | sort -u |
76 | | -} |
77 | | - |
78 | 24 | # ===== VERSION DETERMINATION FUNCTIONS ===== |
79 | 25 |
|
80 | 26 | # Get all git tags in reverse chronological order (newest first) |
@@ -286,14 +232,14 @@ update_files() { |
286 | 232 | return 1 |
287 | 233 | fi |
288 | 234 | zz_log i "Minimal mode: only bumping workspaces with related commits" |
289 | | - workspace_list=$(get_affected_workspaces "$range") |
| 235 | + workspace_list=$(git workspaces -r "$range") |
290 | 236 |
|
291 | 237 | if [ -z "$workspace_list" ]; then |
292 | 238 | zz_log w "No workspaces affected by recent commits - skipping workspace updates" |
293 | 239 | return |
294 | 240 | fi |
295 | 241 | else |
296 | | - workspace_list=$(get_workspace_dirs) |
| 242 | + workspace_list=$(git workspaces) |
297 | 243 | fi |
298 | 244 |
|
299 | 245 | zz_log i "Bumping version in $filename across workspaces to $version" |
|
0 commit comments