@@ -128,12 +128,9 @@ def get_pushed_refs() -> List[str]:
128
128
sys .exit (1 )
129
129
130
130
131
- def get_upstream_branch (local_ref : str ) -> Optional [str ]:
131
+ def get_upstream_branch () -> Optional [str ]:
132
132
"""
133
- Retrieves the upstream branch for a given local ref.
134
-
135
- Args:
136
- local_ref (str): The local ref being pushed.
133
+ Retrieves the upstream branch for the current branch.
137
134
138
135
Returns:
139
136
Optional[str]: The upstream branch name or None if not found.
@@ -146,10 +143,10 @@ def get_upstream_branch(local_ref: str) -> Optional[str]:
146
143
stderr = subprocess .PIPE ,
147
144
text = True ,
148
145
).stdout .strip ()
149
- logger .debug (f"Upstream branch for { local_ref } : { upstream } " )
146
+ logger .debug (f"Upstream branch: { upstream } " )
150
147
return upstream
151
148
except subprocess .CalledProcessError as e :
152
- logger .error (f"Error retrieving upstream branch for { local_ref } : { e .stderr } " )
149
+ logger .error (f"Error retrieving upstream branch: { e .stderr } " )
153
150
return None
154
151
155
152
@@ -353,12 +350,12 @@ def main() -> None:
353
350
logger .info ("No refs being pushed." )
354
351
return
355
352
356
- for local_ref in pushed_refs :
357
- upstream_ref = get_upstream_branch (local_ref )
358
- if not upstream_ref :
359
- logger .warning (f"No upstream branch found for { local_ref } . Skipping." )
360
- continue
353
+ upstream_ref = get_upstream_branch ()
354
+ if not upstream_ref :
355
+ logger .error ("No upstream branch found. Aborting." )
356
+ sys .exit (1 )
361
357
358
+ for local_ref in pushed_refs :
362
359
commits = get_commits_being_pushed (local_ref , upstream_ref )
363
360
if not commits :
364
361
logger .info (f"No new commits to process for { local_ref } ." )
0 commit comments