1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Local push preparation, separate from upload and receiver messages.
/// Completed local work while constructing a prepared push.
///
/// Observers run synchronously and must return promptly. Counts do not describe upload, receiver
/// acceptance or reference publication. Set the preparation cancellation flag to stop at the next
/// cooperative check; one storage read, hash or compression call cannot be interrupted.
///
/// # Examples
///
/// ```
/// use std::sync::atomic::AtomicBool;
///
/// use girt::PackLimits;
/// use girt::push::{PreparationProgress, PreparedPush, PushCommand, PushLimits};
/// use girt::refs::RefName;
/// # let (_directory, _, repo, _, _) = include!("../doctest/remote.rs");
/// # let commit = include!("../doctest/commit.rs");
/// let first = commit(&repo, &[], "First commit")?;
/// let command = PushCommand::new(RefName::new("refs/heads/main")?, None, first);
/// let objects = repo.objects(PackLimits::default())?;
///
/// let mut events = Vec::new();
/// let cancel = AtomicBool::new(false);
/// PreparedPush::new_with_progress(
/// &objects,
/// vec![command],
/// &[],
/// PushLimits::default(),
/// &cancel,
/// |event| events.push(event),
/// )?;
/// assert!(events.contains(&PreparationProgress::Packing { objects: (2, 2) }));
/// assert_eq!(events.last(), Some(&PreparationProgress::Complete));
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```