@@ -798,8 +798,12 @@ def cherry_pick_cli(
798
798
799
799
click .echo ("\U0001F40D \U0001F352 \u26CF " )
800
800
801
- chosen_config_path , config = load_config (config_path )
802
-
801
+ try :
802
+ chosen_config_path , config = load_config (config_path )
803
+ except ValueError as exc :
804
+ click .echo ("You're not inside a Git tree right now! \U0001F645 " , err = True )
805
+ click .echo (exc , err = True )
806
+ sys .exit (- 1 )
803
807
try :
804
808
cherry_picker = CherryPicker (
805
809
pr_remote ,
@@ -813,7 +817,7 @@ def cherry_pick_cli(
813
817
chosen_config_path = chosen_config_path ,
814
818
)
815
819
except InvalidRepoException as ire :
816
- click .echo (ire .args [0 ])
820
+ click .echo (ire .args [0 ], err = True )
817
821
sys .exit (- 1 )
818
822
except ValueError as exc :
819
823
ctx .fail (exc )
@@ -1015,7 +1019,12 @@ def load_config(path=None):
1015
1019
def get_sha1_from (commitish ):
1016
1020
"""Turn 'commitish' into its sha1 hash."""
1017
1021
cmd = ["git" , "rev-parse" , commitish ]
1018
- return subprocess .check_output (cmd ).strip ().decode ("utf-8" )
1022
+ try :
1023
+ return (
1024
+ subprocess .check_output (cmd , stderr = subprocess .PIPE ).strip ().decode ("utf-8" )
1025
+ )
1026
+ except subprocess .CalledProcessError as exc :
1027
+ raise ValueError (exc .stderr .strip ().decode ("utf-8" ))
1019
1028
1020
1029
1021
1030
def reset_stored_config_ref ():
0 commit comments