Skip to content

Commit 1e7d532

Browse files
committed
refactor: use explicit for-loop instead of list comprehension in switch_branch
Addresses review feedback that the comprehension's line-before-for ordering was confusing to read.
1 parent 5f2f717 commit 1e7d532

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

ci.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ def switch_branch(path, branch):
268268
except CalledProcessError:
269269
cur_branch = check_output('git rev-parse HEAD'.split(), cwd=path).decode().strip()
270270
if cur_branch != branch:
271-
branches = check_output('git ls-remote --heads origin'.split(), cwd=path)
272-
branches = [
273-
line.split("refs/heads/", 1)[-1]
274-
for line in branches.decode().strip().split("\n")
275-
if line.strip()
276-
]
271+
raw_branches = check_output('git ls-remote --heads origin'.split(), cwd=path)
272+
branches = []
273+
for line in raw_branches.decode().strip().split("\n"):
274+
if not line.strip():
275+
continue
276+
branches.append(line.split("refs/heads/", 1)[-1])
277277

278278
if branch in branches:
279279
print(f'Switch to branch: {branch} (from {cur_branch})')

0 commit comments

Comments
 (0)