Skip to content

Commit 88422f3

Browse files
Copilotmrjf
andauthored
fix: use git ls-remote for branch discovery instead of git branch -r
Replace `git branch -r --list origin/autoloop/*` with `git ls-remote --heads origin autoloop/*` so that branch discovery works in shallow checkouts where remote-tracking refs aren't present. Agent-Logs-Url: https://github.com/githubnext/autoloop/sessions/2817cf91-682b-41fb-82c1-79eeb961f4f0 Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent f214d89 commit 88422f3

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

.github/workflows/sync-branches.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workflows/sync-branches.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ steps:
3434
return { returncode: result.status, stdout: result.stdout || '', stderr: result.stderr || '' };
3535
}
3636
37-
// List all remote branches matching the autoloop/* pattern
38-
const listResult = git('branch', '-r', '--list', 'origin/autoloop/*');
37+
// Discover all remote branches matching the autoloop/* pattern.
38+
// Use ls-remote instead of 'git branch -r' so we don't depend on
39+
// pre-fetched remote-tracking refs (shallow checkouts won't have them).
40+
const listResult = git('ls-remote', '--heads', 'origin', 'autoloop/*');
3941
if (listResult.returncode !== 0) {
4042
console.log('Failed to list remote branches: ' + listResult.stderr);
4143
process.exit(0);
@@ -44,7 +46,7 @@ steps:
4446
const branches = listResult.stdout.trim().split('\n')
4547
.map(b => b.trim())
4648
.filter(b => b)
47-
.map(b => b.replace('origin/', ''));
49+
.map(b => b.replace(/^.*refs\/heads\//, ''));
4850
4951
if (branches.length === 0) {
5052
console.log('No autoloop/* branches found. Nothing to sync.');

0 commit comments

Comments
 (0)