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

Method set_git_town_parent

src/git.rs:547–575  ·  view source on GitHub ↗

Set git-town parent branch configuration This writes to git config without triggering any git operations. Should be called within a repo lock to prevent concurrent config writes. # Arguments `repo_path` - Path to the repository where the config should be set `branch_name` - Name of the branch to set the parent for `parent_branch` - Name of the parent branch

(
        &self,
        repo_path: &Path,
        branch_name: &str,
        parent_branch: &str,
    )

Source from the content-addressed store, hash-verified

545 /// * `branch_name` - Name of the branch to set the parent for
546 /// * `parent_branch` - Name of the parent branch
547 pub async fn set_git_town_parent(
548 &self,
549 repo_path: &Path,
550 branch_name: &str,
551 parent_branch: &str,
552 ) -> Result<(), String> {
553 tokio::task::spawn_blocking({
554 let repo_path = repo_path.to_owned();
555 let branch_name = branch_name.to_owned();
556 let parent_branch = parent_branch.to_owned();
557 move || -> Result<(), String> {
558 let repo = git2::Repository::open(&repo_path)
559 .map_err(|e| format!("Failed to open repository: {e}"))?;
560
561 let mut config = repo
562 .config()
563 .map_err(|e| format!("Failed to get repository config: {e}"))?;
564
565 let key = format!("git-town-branch.{}.parent", branch_name);
566 config
567 .set_str(&key, &parent_branch)
568 .map_err(|e| format!("Failed to set git-town parent: {e}"))?;
569
570 Ok(())
571 }
572 })
573 .await
574 .map_err(|e| format!("Task join error: {e}"))?
575 }
576
577 /// Fetch changes from the copied repository back to the main repository.
578 /// Returns a `FetchResult` with `has_changes: false` if the branch has no new commits.

Callers 3

fetch_changesMethod · 0.80
test_set_git_town_parentFunction · 0.80

Calls

no outgoing calls

Tested by 2

test_set_git_town_parentFunction · 0.64