@@ -62,14 +62,6 @@ def find_sdk_name_changes(
6262 return added , removed
6363
6464
65- def git_merge_base (base : str , head : str ) -> str :
66- return subprocess .check_output (
67- ["git" , "merge-base" , base , head ],
68- text = True ,
69- stderr = subprocess .PIPE ,
70- ).strip ()
71-
72-
7365def git_show (ref : str , path : str ) -> str :
7466 try :
7567 return subprocess .check_output (
@@ -86,8 +78,7 @@ def git_show(ref: str, path: str) -> str:
8678def read_config_source (base : str | None , head : str | None , config_path : str ) -> tuple [str , str ]:
8779 if base is None or head is None :
8880 raise ValueError ("Both base and head refs are required" )
89- merge_base = git_merge_base (base , head )
90- return git_show (merge_base , config_path ), git_show (head , config_path )
81+ return git_show (base , config_path ), git_show (head , config_path )
9182
9283
9384def format_changes (added : list [str ], removed : list [str ]) -> str :
@@ -112,22 +103,25 @@ def main(argv: list[str] | None = None) -> int:
112103 parser .add_argument ("--config-path" , default = CONFIG_PATH )
113104 args = parser .parse_args (argv )
114105
115- if args .base_file and args .head_file :
116- base_content = args .base_file .read_text (encoding = "utf-8" )
117- head_content = args .head_file .read_text (encoding = "utf-8" )
118- elif args .base and args .head :
119- base_content , head_content = read_config_source (
120- args .base , args .head , args .config_path
121- )
122- else :
123- parser .error ("Provide --base/--head or --base-file/--head-file" )
124-
125106 try :
107+ if args .base_file and args .head_file :
108+ base_content = args .base_file .read_text (encoding = "utf-8" )
109+ head_content = args .head_file .read_text (encoding = "utf-8" )
110+ elif args .base and args .head :
111+ base_content , head_content = read_config_source (
112+ args .base , args .head , args .config_path
113+ )
114+ else :
115+ parser .error ("Provide --base/--head or --base-file/--head-file" )
116+
126117 base_sdk = parse_sdk_constants (base_content )
127118 head_sdk = parse_sdk_constants (head_content )
128119 except ValueError as error :
129120 print (f"error: { error } " , file = sys .stderr )
130121 return 1
122+ except subprocess .CalledProcessError as error :
123+ print (f"error: git command failed: { ' ' .join (error .cmd )} " , file = sys .stderr )
124+ return 1
131125
132126 added , removed = find_sdk_name_changes (base_sdk , head_sdk )
133127 print (format_changes (added , removed ))
0 commit comments