Skip to content

Commit d571101

Browse files
committed
Improve git branch fetching
1 parent c8ee27d commit d571101

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/main.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ async function run(): Promise<void> {
3030

3131
// Create the oprhan github-meta branch if it doesn't exist
3232
const branch = core.getInput('branch')
33-
const branchExists =
34-
execSync(`git branch --list ${branch}`).toString().trim() !== ''
33+
const branchExists = await exec('git', [
34+
'fetch',
35+
'origin',
36+
branch,
37+
'--depth',
38+
'1',
39+
])
3540

36-
if (!branchExists) {
41+
if (branchExists !== 0) {
3742
core.info(`No ${branch} branch exists, creating...`)
3843
await exec('git', ['checkout', '--orphan', branch])
3944
await exec('git', ['rm', '-rf', '.'])
@@ -46,7 +51,6 @@ async function run(): Promise<void> {
4651
} else {
4752
core.info(`Checking out ${branch}`)
4853
await exec('git', ['checkout', '-t', `origin/${branch}`])
49-
await exec('git', ['pull'])
5054
}
5155

5256
// open the database

0 commit comments

Comments
 (0)