(directory: &Path)
| 142 | |
| 143 | impl Publisher { |
| 144 | fn new(directory: &Path) -> Self { |
| 145 | let repo = Repository::init(directory).unwrap(); |
| 146 | |
| 147 | fs::create_dir_all(directory.join("nested")).unwrap(); |
| 148 | fs::write(directory.join("nested/alpha.txt"), b"alpha body\n").unwrap(); |
| 149 | record_all(&repo, "first"); |
| 150 | fs::write(directory.join("nested/alpha.txt"), b"alpha body v2\n").unwrap(); |
| 151 | record_all(&repo, "second"); |
| 152 | fs::write(directory.join("empty.txt"), b"").unwrap(); |
| 153 | record_all(&repo, "third"); |
| 154 | |
| 155 | let view = repo.current_view().to_string(); |
| 156 | let identity = repo.view_identity(&view).unwrap(); |
| 157 | let ordered: Vec<Hash> = repo |
| 158 | .effective_history(Some(&view)) |
| 159 | .unwrap() |
| 160 | .iter() |
| 161 | .map(|entry| entry.hash) |
| 162 | .collect(); |
| 163 | |
| 164 | let policy = ConversionPolicy::new(GitHashAlgorithm::Sha1); |
| 165 | let project = repo.project_tree(&view, &policy).unwrap(); |
| 166 | let git = git2::Repository::init_opts( |
| 167 | directory.join("bridge.git"), |
| 168 | git2::RepositoryInitOptions::new().bare(true), |
| 169 | ) |
| 170 | .unwrap(); |
| 171 | let (commit, raw_commit) = bind_projection_to_commit(&git, &project); |
| 172 | Self { |
| 173 | repo, |
| 174 | ordered, |
| 175 | set_id: identity.set_id, |
| 176 | merkle: identity.merkle, |
| 177 | commit_hex: commit.to_string(), |
| 178 | tree_hex: hex_oid(&project.git.root), |
| 179 | raw_commit, |
| 180 | view, |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | fn binding(&self, seed: u8) -> GitStateBinding { |
| 185 | signed_binding( |
nothing calls this directly
no test coverage detected