MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / get_current_commit

Function get_current_commit

src/git_operations.rs:339–359  ·  view source on GitHub ↗

Get the current commit SHA # Errors Returns an error if: - The repository cannot be opened - HEAD cannot be resolved (e.g., empty repository with no commits) - The HEAD reference does not point to a valid commit

(repo_path: &Path)

Source from the content-addressed store, hash-verified

337/// - HEAD cannot be resolved (e.g., empty repository with no commits)
338/// - The HEAD reference does not point to a valid commit
339pub async fn get_current_commit(repo_path: &Path) -> Result<String, String> {
340 tokio::task::spawn_blocking({
341 let repo_path = repo_path.to_owned();
342 move || -> Result<String, String> {
343 let repo = Repository::open(&repo_path)
344 .map_err(|e| format!("Failed to open repository: {e}"))?;
345
346 let head = repo
347 .head()
348 .map_err(|e| format!("Failed to get HEAD: {e}"))?;
349
350 let commit = head
351 .peel_to_commit()
352 .map_err(|e| format!("Failed to get commit from HEAD: {e}"))?;
353
354 Ok(commit.id().to_string())
355 }
356 })
357 .await
358 .map_err(|e| format!("Task join error: {e}"))?
359}
360
361/// Create a branch from a specific commit
362pub async fn create_branch_from_commit(

Callers 7

test_get_current_commitFunction · 0.85
test_clone_localFunction · 0.85
fetch_changesMethod · 0.85
buildMethod · 0.85
prepare_child_taskMethod · 0.85

Calls

no outgoing calls

Tested by 4

test_get_current_commitFunction · 0.68
test_clone_localFunction · 0.68