|
@ -17,7 +17,7 @@ pub struct Checkout<_C, C, P, S, B> { |
|
|
phantom: PhantomData<_C>,
|
|
|
phantom: PhantomData<_C>,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<C, _C, P, S, B> Checkout<_C, C, P, S, B> {
|
|
|
|
|
|
|
|
|
impl<_C, C, P, S, B> Checkout<_C, C, P, S, B> {
|
|
|
pub fn new(target: P, source: S, branch: B, command_runner: C) -> Self {
|
|
|
pub fn new(target: P, source: S, branch: B, command_runner: C) -> Self {
|
|
|
Self {
|
|
|
Self {
|
|
|
target,
|
|
|
target,
|
|
@ -29,7 +29,7 @@ impl<C, _C, P, S, B> Checkout<_C, C, P, S, B> { |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
impl<C: CommandRunner, _C: Borrow<C>, P: AsRef<Path>, S, B> Checkout<C, _C, P, S, B> {
|
|
|
|
|
|
|
|
|
impl<_C: CommandRunner, C: Borrow<_C>, P: AsRef<Path>, S, B> Checkout<_C, C, P, S, B> {
|
|
|
async fn run_git(&self, args: &[impl AsRef<OsStr>]) -> Result<Vec<u8>, Box<dyn Error>> {
|
|
|
async fn run_git(&self, args: &[impl AsRef<OsStr>]) -> Result<Vec<u8>, Box<dyn Error>> {
|
|
|
let mut new_args = Vec::with_capacity(args.len() + 2);
|
|
|
let mut new_args = Vec::with_capacity(args.len() + 2);
|
|
|
new_args.extend_from_slice(args!["-C", self.target.as_ref()]);
|
|
|
new_args.extend_from_slice(args!["-C", self.target.as_ref()]);
|
|
@ -43,8 +43,8 @@ impl<C: CommandRunner, _C: Borrow<C>, P: AsRef<Path>, S, B> Checkout<C, _C, P, S |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
#[async_trait(?Send)]
|
|
|
impl<C: CommandRunner, _C: Borrow<C>, P: AsRef<Path>, S: AsRef<str>, B: AsRef<str>> Symbol
|
|
|
|
|
|
for Checkout<C, _C, P, S, B>
|
|
|
|
|
|
|
|
|
impl<_C: CommandRunner, C: Borrow<_C>, P: AsRef<Path>, S: AsRef<str>, B: AsRef<str>> Symbol
|
|
|
|
|
|
for Checkout<_C, C, P, S, B>
|
|
|
{
|
|
|
{
|
|
|
async fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
|
|
async fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
|
|
|
if !self.target.as_ref().exists() {
|
|
|
if !self.target.as_ref().exists() {
|
|
@ -146,7 +146,6 @@ mod test { |
|
|
["-C", "target", "rev-list", "-1", "HEAD"],
|
|
|
["-C", "target", "rev-list", "-1", "HEAD"],
|
|
|
]
|
|
|
]
|
|
|
);
|
|
|
);
|
|
|
drop(first_two_args);
|
|
|
|
|
|
assert_eq!(args[2], ["-C", "target", "rev-list", "-1", "FETCH_HEAD"]);
|
|
|
assert_eq!(args[2], ["-C", "target", "rev-list", "-1", "FETCH_HEAD"]);
|
|
|
|
|
|
|
|
|
assert!((end - start).as_millis() >= 100);
|
|
|
assert!((end - start).as_millis() >= 100);
|
|
|