File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -758,7 +758,16 @@ pub fn smartlog(
758
758
reverse,
759
759
} = options;
760
760
761
- let repo = Repo :: from_dir ( & git_run_info. working_directory ) ?;
761
+ let repo = match Repo :: from_dir ( & git_run_info. working_directory ) {
762
+ Ok ( repo) => repo,
763
+ Err ( err) => {
764
+ writeln ! (
765
+ effects. get_error_stream( ) ,
766
+ "{err}" ,
767
+ ) ?;
768
+ return Ok ( Err ( ExitCode ( 1 ) ) ) ;
769
+ }
770
+ } ;
762
771
let head_info = repo. get_head_info ( ) ?;
763
772
let conn = repo. get_db_conn ( ) ?;
764
773
let event_log_db = EventLogDb :: new ( & conn) ?;
Original file line number Diff line number Diff line change @@ -650,6 +650,24 @@ fn test_smartlog_sparse_main_false_head() -> eyre::Result<()> {
650
650
Ok ( ( ) )
651
651
}
652
652
653
+ #[ test]
654
+ fn test_error_without_panic_on_missing_repo ( ) -> eyre:: Result < ( ) > {
655
+ let git = make_git ( ) ?;
656
+
657
+ {
658
+ let ( _stdout, stderr) = git. branchless_with_options (
659
+ "smartlog" ,
660
+ & [ ] ,
661
+ & GitRunOptions {
662
+ expected_exit_code : 1 ,
663
+ ..Default :: default ( )
664
+ } ) ?;
665
+ insta:: assert_snapshot!( stderr, @"could not open repository: could not find repository from '<repo-path>'; class=Repository (6); code=NotFound (-3)" ) ;
666
+ }
667
+
668
+ Ok ( ( ) )
669
+ }
670
+
653
671
#[ test]
654
672
fn test_smartlog_hidden ( ) -> eyre:: Result < ( ) > {
655
673
let git = make_git ( ) ?;
You can’t perform that action at this time.
0 commit comments