Skip to content

Commit 02d5486

Browse files
committed
test
1 parent e99e8ab commit 02d5486

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

babs/utils.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,15 @@ def get_results_branches(ria_directory):
397397
if not branches:
398398
# Check if 'origin' remote exists (indicates a cloned repository)
399399
check_remote = subprocess.run(
400-
['git', 'remote', 'show', 'origin'],
400+
['git', 'remote', 'get-url', 'origin'],
401401
cwd=ria_directory,
402402
capture_output=True,
403403
text=True,
404404
)
405405
# Only check remote branches if 'origin' remote exists
406406
# (this indicates it's a cloned repo like merge_ds, not the original RIA)
407407
if check_remote.returncode == 0:
408+
# First try git branch -r (shows remote-tracking branches that have been fetched)
408409
branch_output_remote = subprocess.run(
409410
['git', 'branch', '-r', '--list'],
410411
cwd=ria_directory,
@@ -425,6 +426,30 @@ def get_results_branches(ria_directory):
425426
for b in remote_branch_lines
426427
if b.strip().replace('* ', '').startswith('origin/job-')
427428
]
429+
430+
# If git branch -r didn't find branches, try git ls-remote
431+
# (this queries the remote directly and works even if refs weren't fetched)
432+
# This is useful for cloned repos where remote-tracking branches might not be set up
433+
if not remote_branches:
434+
ls_remote_output = subprocess.run(
435+
['git', 'ls-remote', '--heads', 'origin'],
436+
cwd=ria_directory,
437+
capture_output=True,
438+
text=True,
439+
)
440+
441+
if ls_remote_output.returncode == 0 and ls_remote_output.stdout.strip():
442+
# Parse output: each line is "SHA\trefs/heads/branch-name"
443+
for line in ls_remote_output.stdout.strip().split('\n'):
444+
parts = line.split('\t')
445+
if len(parts) == 2:
446+
ref_name = parts[1] # e.g., "refs/heads/job-1-1-sub-01"
447+
# Extract branch name (remove 'refs/heads/' prefix)
448+
if ref_name.startswith('refs/heads/'):
449+
branch_name = ref_name.replace('refs/heads/', '')
450+
if branch_name.startswith('job-'):
451+
remote_branches.append(branch_name)
452+
428453
branches = remote_branches
429454

430455
return branches

0 commit comments

Comments
 (0)