MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / read_stubs_lock

Function read_stubs_lock

build.rs:318–349  ·  view source on GitHub ↗

Read `stubs.lock` and return the pinned commit + hash. Panics if the file is missing or malformed — `stubs.lock` is checked into version control and must always be present.

(manifest_dir: &str)

Source from the content-addressed store, hash-verified

316/// Panics if the file is missing or malformed — `stubs.lock` is checked
317/// into version control and must always be present.
318fn read_stubs_lock(manifest_dir: &str) -> StubsLock {
319 let lock_path = Path::new(manifest_dir).join("stubs.lock");
320 let content = fs::read_to_string(&lock_path)
321 .unwrap_or_else(|e| panic!("Failed to read stubs.lock: {}\nThis file is required and should be checked into version control.", e));
322
323 let mut repo: Option<String> = None;
324 let mut commit: Option<String> = None;
325 let mut sha256: Option<String> = None;
326
327 for line in content.lines() {
328 let line = line.trim();
329 if line.is_empty() || line.starts_with('#') {
330 continue;
331 }
332 if let Some((key, value)) = line.split_once('=') {
333 let key = key.trim();
334 let value = value.trim().trim_matches('"');
335 match key {
336 "repo" => repo = Some(value.to_string()),
337 "commit" => commit = Some(value.to_string()),
338 "sha256" => sha256 = Some(value.to_string()),
339 _ => {}
340 }
341 }
342 }
343
344 StubsLock {
345 repo: repo.unwrap_or_else(|| "JetBrains/phpstorm-stubs".to_string()),
346 commit: commit.expect("stubs.lock is missing 'commit' field"),
347 sha256: sha256.expect("stubs.lock is missing 'sha256' field"),
348 }
349}
350
351/// Compute the SHA-256 hex digest of a byte slice.
352fn sha256_hex(data: &[u8]) -> String {

Callers 1

mainFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected