Skip to content

Commit eba845f

Browse files
authored
Merge pull request #20 from githubnext/copilot/fix-branch-discovery-without-remotes
Use git ls-remote for autoloop branch discovery
2 parents 23af2cc + 88422f3 commit eba845f

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
@@ -35,8 +35,10 @@ steps:
3535
return { returncode: result.status, stdout: result.stdout || '', stderr: result.stderr || '' };
3636
}
3737
38-
// List all remote branches matching the autoloop/* pattern
39-
const listResult = git('branch', '-r', '--list', 'origin/autoloop/*');
38+
// Discover all remote branches matching the autoloop/* pattern.
39+
// Use ls-remote instead of 'git branch -r' so we don't depend on
40+
// pre-fetched remote-tracking refs (shallow checkouts won't have them).
41+
const listResult = git('ls-remote', '--heads', 'origin', 'autoloop/*');
4042
if (listResult.returncode !== 0) {
4143
console.log('Failed to list remote branches: ' + listResult.stderr);
4244
process.exit(0);
@@ -45,7 +47,7 @@ steps:
4547
const branches = listResult.stdout.trim().split('\n')
4648
.map(b => b.trim())
4749
.filter(b => b)
48-
.map(b => b.replace('origin/', ''));
50+
.map(b => b.replace(/^.*refs\/heads\//, ''));
4951
5052
if (branches.length === 0) {
5153
console.log('No autoloop/* branches found. Nothing to sync.');

0 commit comments

Comments
 (0)