Skip to content

Commit 1e7f2ce

Browse files
authored
Update land.py to delete head ref separately from orig ref and base ref (#291)
1 parent 59ba255 commit 1e7f2ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/ghstack/land.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,13 @@ def main(
187187
base_ref = re.sub(r"/orig$", "/base", orig_ref)
188188
head_ref = re.sub(r"/orig$", "/head", orig_ref)
189189
try:
190-
sh.git("push", remote_name, "--delete", orig_ref, base_ref, head_ref)
190+
sh.git("push", remote_name, "--delete", orig_ref, base_ref)
191+
except RuntimeError:
192+
# Whatever, keep going
193+
logging.warning("Failed to delete branch, continuing", exc_info=True)
194+
# Try deleting head_ref separately since often after it's merged it doesn't exist anymore
195+
try:
196+
sh.git("push", remote_name, "--delete", head_ref)
191197
except RuntimeError:
192198
# Whatever, keep going
193199
logging.warning("Failed to delete branch, continuing", exc_info=True)

0 commit comments

Comments
 (0)