@ -129,9 +129,10 @@ impl<'a> GitView<'a> {
None = > Ok ( Cow ::Borrowed ( branch ) ) ,
None = > Ok ( Cow ::Borrowed ( branch ) ) ,
} ;
} ;
}
}
// Default branch couldn't be retrieved, just use the local branch
GitOutput ::Err ( _ ) = > Err ( AppError ::new (
// (this WILL result in a 404 error on the user but better than failing?)
ErrorType ::MissingDefaultBranch ,
GitOutput ::Err ( _ ) = > Ok ( Cow ::Borrowed ( branch ) ) ,
format! ( "Could not verify '{remote}/{branch}' exists and could not retrieve default branch" )
) ) ,
} ,
} ,
}
}
}
}
@ -633,7 +634,7 @@ mod lib_tests {
#[ test ]
#[ test ]
fn is_branch_and_fail_to_get_default ( ) {
fn is_branch_and_fail_to_get_default ( ) {
let handler = GitView ::default ( ) ;
let handler = GitView ::default ( ) ;
let local = Local ::Branch ( Cow ::Borrowed ( " main ") ) ;
let local = Local ::Branch ( Cow ::Borrowed ( " testing ") ) ;
let mut mock = MockGitTrait ::default ( ) ;
let mut mock = MockGitTrait ::default ( ) ;
mock . expect_get_upstream_branch ( )
mock . expect_get_upstream_branch ( )
@ -643,8 +644,11 @@ mod lib_tests {
let actual_upstream_branch = handler . get_remote_reference ( & local , "origin" , & mock ) ;
let actual_upstream_branch = handler . get_remote_reference ( & local , "origin" , & mock ) ;
assert! ( actual_upstream_branch . is_ok ( ) ) ;
assert! ( actual_upstream_branch . is_err ( ) ) ;
assert_eq! ( actual_upstream_branch . unwrap ( ) , "main" )
assert_eq! (
actual_upstream_branch . unwrap_err ( ) . error_str ,
"Could not verify 'origin/testing' exists and could not retrieve default branch"
) ;
}
}
#[ test ]
#[ test ]