MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / transfer_to_client

Function transfer_to_client

atomic-cli/tests/it/git_binding_cb6b_test.rs:128–184  ·  view source on GitHub ↗

Push the branch and the binding namespace to a bare remote, then clone and configure the RFC §8.6 fetch refspec on the client.

(publisher: &Path, remote_dir: &Path, client: &Path)

Source from the content-addressed store, hash-verified

126/// Push the branch and the binding namespace to a bare remote, then clone
127/// and configure the RFC §8.6 fetch refspec on the client.
128fn transfer_to_client(publisher: &Path, remote_dir: &Path, client: &Path) {
129 let run_git = |dir: &Path, args: &[&str], context: &str| {
130 let out = Command::new("git")
131 .args(args)
132 .current_dir(dir)
133 .output()
134 .unwrap_or_else(|error| panic!("{context}: {error}"));
135 assert!(
136 out.status.success(),
137 "{context} failed: {}",
138 output_text(&out)
139 );
140 };
141 run_git(
142 publisher,
143 &[
144 "push",
145 remote_dir.to_str().unwrap(),
146 "refs/heads/*:refs/heads/*",
147 "refs/atomic/bindings/*:refs/atomic/bindings/*",
148 ],
149 "push branch + binding namespace",
150 );
151 // libgit2 and the system Git executable can use different default branch
152 // names. A push does not update a bare remote's symbolic HEAD; point it
153 // at the published branch so the fresh clone actually checks it out.
154 let publisher_git = git2::Repository::open(publisher).expect("publisher git");
155 let head = publisher_git.head().expect("publisher HEAD");
156 let branch_ref = head.name().expect("named publisher branch");
157 assert!(branch_ref.starts_with("refs/heads/"));
158 run_git(
159 remote_dir,
160 &["symbolic-ref", "HEAD", branch_ref],
161 "set remote default branch",
162 );
163 run_git(
164 publisher.parent().unwrap(),
165 &[
166 "clone",
167 remote_dir.to_str().unwrap(),
168 client.file_name().unwrap().to_str().unwrap(),
169 ],
170 "clone to client",
171 );
172 // The RFC §8.6 enable-time fetch refspec for binding refs.
173 run_git(
174 client,
175 &[
176 "config",
177 "--add",
178 "remote.origin.fetch",
179 "+refs/atomic/bindings/*:refs/atomic/bindings/*",
180 ],
181 "configure binding fetch refspec",
182 );
183 run_git(client, &["fetch", "origin"], "fetch binding refs");
184}
185

Calls 8

openFunction · 0.85
parentMethod · 0.80
run_gitFunction · 0.70
outputMethod · 0.45
unwrapMethod · 0.45
headMethod · 0.45
nameMethod · 0.45
file_nameMethod · 0.45

Tested by

no test coverage detected