Commit a4ff0c2
feat: Add CMake FetchContent support to updater (#104)
* feat: Add CMake FetchContent support to updater
Implements support for updating CMake FetchContent_Declare() statements
in addition to existing submodules, properties files, and scripts.
Key features:
- Support for path.cmake#DepName and auto-detection syntax
- Hash vs tag detection with hash format preservation
- Hash-to-tag resolution for version comparison
- GitHub Actions output integration
- Comprehensive test coverage (23 tests)
Resolves: #91
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix: Complete CMake FetchContent implementation
Critical fixes and improvements:
- Fix GitHub Actions workflow validation to allow # character in paths
- Update documentation with CMake examples and usage
- Improve comment handling in hash updates
- Implement proper ancestry validation for hash updates
- Test with real console SDK CMake files
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* docs: Fix CMake examples to be more logical
- sentry-native.cmake now uses auto-detection (single dependency)
- dependencies.cmake now shows explicit dependency name syntax
- Better reflects real-world usage patterns
* docs: Refactor path input description into cleaner sublist
- Split long bullet point into structured sublist
- Clear separation of different path format types
- Better readability for CMake file options
* fix: cleanup CMake file handling in update-dependency script
* fix: ensure newline at end of file in Update-CMakeFile function
* refactor: Use cross-platform temp directory approach
- Replace $env:TEMP with [System.IO.Path]::GetTempPath()
- Use [System.Guid]::NewGuid() for unique directory names
- More robust cross-platform compatibility
* security: Fix ancestry validation to fail safely
- Return false instead of true when ancestry validation fails
- Change warning to error message for clarity
- Prevents potentially incorrect updates when validation is uncertain
- Follows fail-safe principle for security-critical operations
* refactor: Simplify GIT_TAG line replacement logic
- Always replace entire line content after GIT_TAG
- Removes potentially outdated version-specific comments
- Simplifies regex pattern (no separate hash/tag logic needed)
- Cleaner and more predictable behavior
* fix: Add proper error handling for git ls-remote commands
- Check $LASTEXITCODE after git ls-remote calls
- Prevent parsing error messages as commit hashes
- Fixes potential corruption of CMake files with 'fatal:' etc.
- Applies to both Update-CMakeFile and Find-TagForHash functions
Fixes critical bug where network failures could corrupt dependency files.
* test: Add missing hash-to-hash update test case
- Tests updating from one git hash to a newer tag's hash
- Covers important scenario of hash-to-hash updates
- Verifies hash format preservation and comment replacement
- Ensures old hash and comments are properly removed
* refactor: Inline test data and group related test cases
- Move CMake test data from external files to inline here-strings
- Group related test scenarios into single test cases for better readability
- Reduce test count from 16 to 6 while maintaining same coverage
- Remove external testdata/cmake/ directory (no longer needed)
- Improve test maintainability - all test input/output visible in one place
Test groupings:
- Parse scenarios: basic, auto-detect, hash, complex formatting
- Multiple deps: auto-detection errors, explicit selection
- Error scenarios: missing deps, missing repo/tag
- Hash resolution: null results, network failures
- Update scenarios: tag-to-tag, hash-to-hash, complex formatting
- Update errors: missing dependency updates
* refactor: Improve test structure with shared data and individual cases
- Move test data creation to Context BeforeAll level
- Restore individual test cases (16 total) for focused testing
- Eliminate data duplication while keeping inline visibility
- Best of both worlds: shared setup + granular test cases
Structure:
- Context BeforeAll: Creates shared test files with inline data
- Individual It blocks: Reference shared files for specific scenarios
- Clear test names and focused assertions per test case
* refactor: Reorganize test hierarchy for better clarity
- Promote function names to Describe level (Parse-CMakeFetchContent, Find-TagForHash, Update-CMakeFile)
- Group tests by CMake file type at Context level
- Each Context has its own test data (no duplication)
- Clear logical organization: function -> file type -> specific tests
Structure:
├── Describe 'Parse-CMakeFetchContent'
│ ├── Context 'Basic single dependency file' (3 tests)
│ ├── Context 'Hash-based dependency file' (1 test)
│ ├── Context 'Complex formatting file' (1 test)
│ ├── Context 'Multiple dependencies file' (2 tests)
│ └── Context 'Malformed files' (2 tests)
├── Describe 'Find-TagForHash'
│ └── Context 'Hash resolution scenarios' (2 tests)
└── Describe 'Update-CMakeFile'
├── Context 'Basic tag updates' (3 tests)
├── Context 'Hash updates' (1 test)
└── Context 'Complex formatting' (1 test)
* test: Use exact hash instead of regex pattern in assertion
- Replace generic pattern [a-f0-9]{40} with actual 0.11.0 hash
- More precise assertion: 3bd091313ae97be90be62696a2babe591a988eb8
- Consistent with integration test data expectations
- Eliminates ambiguity in test validation
* test: Use exact hash in integration test assertion
- Replace generic pattern [a-f0-9]{40} # \d+\.\d+\.\d+ with exact values
- More precise assertion: 3bd091313ae97be90be62696a2babe591a988eb8 # 0\.11\.0
- Matches unit test precision and validates exact expected output
- Eliminates ambiguity in hash-to-tag update validation
* test: Use exact version in remaining integration test assertions
- Replace generic \d+\.\d+\.\d+ patterns with exact 0\.11\.0
- More precise assertions for explicit dependency and auto-detection tests
- Completes migration from generic patterns to exact expected values
- Ensures deterministic test validation across all CMake tests
* revert: Use generic patterns in integration tests without version constraints
- Revert exact version assertions where UpdateDependency gets latest version
- Keep generic patterns \d+\.\d+\.\d+ and [a-f0-9]{40} for future-proof tests
- Integration tests call UpdateDependency without pattern constraints
- Latest version will change over time (0.11.0 → 0.12.0, etc.)
- Unit tests can keep exact values since they specify exact versions
* docs: Add changelog entry for CMake FetchContent support
- Document new CMake FetchContent functionality in CHANGELOG.md
- References PR #104 for automated dependency updates
- Follows existing changelog format and conventions
* Add parameter validation to CMake helper functions
Added robust parameter validation with type constraints to all CMake helper functions:
- Parse-CMakeFetchContent: Validates file path exists and dependency name format
- Find-TagForHash: Validates repository URL and 40-char hash format
- Test-HashAncestry: Validates repository URL and hash formats
- Update-CMakeFile: Validates file path, dependency name, and new value
This prevents misuse, improves error handling, and addresses security concerns around parameter injection attacks.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Add dependency name validation in update-dependency.ps1
Added validation to ensure CMake dependency names follow proper naming conventions and prevent potential regex injection attacks. Dependency names must start with a letter and contain only alphanumeric characters, underscores, dots, or hyphens.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 672dd4d commit a4ff0c2
File tree
7 files changed
+790
-6
lines changed- .github/workflows
- updater
- scripts
- tests
7 files changed
+790
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
91 | | - | |
92 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
49 | 67 | | |
50 | 68 | | |
51 | 69 | | |
52 | 70 | | |
53 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
54 | 78 | | |
55 | 79 | | |
56 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
19 | 40 | | |
20 | 41 | | |
21 | 42 | | |
| |||
41 | 62 | | |
42 | 63 | | |
43 | 64 | | |
44 | | - | |
| 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 | + | |
45 | 91 | | |
46 | 92 | | |
47 | 93 | | |
| |||
99 | 145 | | |
100 | 146 | | |
101 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
102 | 151 | | |
103 | 152 | | |
104 | 153 | | |
| |||
0 commit comments