mirror of
https://github.com/actions/checkout.git
synced 2026-07-18 03:50:07 +08:00
use --not instead of listing refs
This commit is contained in:
parent
0c607adfe5
commit
3f843303fa
2 changed files with 24 additions and 22 deletions
23
dist/index.js
vendored
23
dist/index.js
vendored
|
|
@ -41988,14 +41988,17 @@ async function uploadBranchDelta(settings) {
|
||||||
info(`Branch delta upload skipped (${grant.kind})`);
|
info(`Branch delta upload skipped (${grant.kind})`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const excludes = await baseRefExcludes(repoPath);
|
if (!(await hasBaseRefs(repoPath))) {
|
||||||
if (excludes.length === 0) {
|
|
||||||
info('No base refs to diff against; branch delta skipped');
|
info('No base refs to diff against; branch delta skipped');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tmp = tempBundlePath('branch');
|
const tmp = tempBundlePath('branch');
|
||||||
try {
|
try {
|
||||||
await exec_exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha]);
|
await exec_exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha]);
|
||||||
|
// Exclude the base with a single --glob, not one `^ref` arg per ref: a large repo
|
||||||
|
// has hundreds of base refs, and that many args overflows the Windows command-line
|
||||||
|
// limit (ENAMETOOLONG). The glob matches the multi-level seeded refs and yields the
|
||||||
|
// same base-relative (order-free) delta.
|
||||||
await exec_exec('git', [
|
await exec_exec('git', [
|
||||||
'-C',
|
'-C',
|
||||||
repoPath,
|
repoPath,
|
||||||
|
|
@ -42003,7 +42006,8 @@ async function uploadBranchDelta(settings) {
|
||||||
'create',
|
'create',
|
||||||
tmp,
|
tmp,
|
||||||
UPLOAD_TIP_REF,
|
UPLOAD_TIP_REF,
|
||||||
...excludes
|
'--not',
|
||||||
|
`--glob=${BASE_REFNS}/*`
|
||||||
]);
|
]);
|
||||||
await httpPut(grant.url, tmp);
|
await httpPut(grant.url, tmp);
|
||||||
info(`Uploaded branch delta for '${plan.refKey}'`);
|
info(`Uploaded branch delta for '${plan.refKey}'`);
|
||||||
|
|
@ -42015,15 +42019,12 @@ async function uploadBranchDelta(settings) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// `^refname` for every seeded base ref — the exclusion set that makes the delta bundle
|
// Whether any base ref was seeded — the guard that keeps the delta base-relative. The
|
||||||
// base-relative (and therefore order-free).
|
// base is excluded by glob (see uploadBranchDelta), so we only need existence here.
|
||||||
async function baseRefExcludes(repoPath) {
|
async function hasBaseRefs(repoPath) {
|
||||||
let out = '';
|
let out = '';
|
||||||
await exec_exec('git', ['-C', repoPath, 'for-each-ref', '--format=^%(refname)', BASE_REFNS], { silent: true, listeners: { stdout: (d) => (out += d.toString()) } });
|
await exec_exec('git', ['-C', repoPath, 'for-each-ref', '--count=1', '--format=1', BASE_REFNS], { silent: true, listeners: { stdout: (d) => (out += d.toString()) } });
|
||||||
return out
|
return out.trim().length > 0;
|
||||||
.split('\n')
|
|
||||||
.map(s => s.trim())
|
|
||||||
.filter(Boolean);
|
|
||||||
}
|
}
|
||||||
async function downloadTo(url, dest) {
|
async function downloadTo(url, dest) {
|
||||||
const res = await fetch(url, {
|
const res = await fetch(url, {
|
||||||
|
|
|
||||||
|
|
@ -254,8 +254,7 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise<void> {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const excludes = await baseRefExcludes(repoPath)
|
if (!(await hasBaseRefs(repoPath))) {
|
||||||
if (excludes.length === 0) {
|
|
||||||
core.info('No base refs to diff against; branch delta skipped')
|
core.info('No base refs to diff against; branch delta skipped')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -263,6 +262,10 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise<void> {
|
||||||
const tmp = tempBundlePath('branch')
|
const tmp = tempBundlePath('branch')
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha])
|
await exec.exec('git', ['-C', repoPath, 'update-ref', UPLOAD_TIP_REF, sha])
|
||||||
|
// Exclude the base with a single --glob, not one `^ref` arg per ref: a large repo
|
||||||
|
// has hundreds of base refs, and that many args overflows the Windows command-line
|
||||||
|
// limit (ENAMETOOLONG). The glob matches the multi-level seeded refs and yields the
|
||||||
|
// same base-relative (order-free) delta.
|
||||||
await exec.exec('git', [
|
await exec.exec('git', [
|
||||||
'-C',
|
'-C',
|
||||||
repoPath,
|
repoPath,
|
||||||
|
|
@ -270,7 +273,8 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise<void> {
|
||||||
'create',
|
'create',
|
||||||
tmp,
|
tmp,
|
||||||
UPLOAD_TIP_REF,
|
UPLOAD_TIP_REF,
|
||||||
...excludes
|
'--not',
|
||||||
|
`--glob=${BASE_REFNS}/*`
|
||||||
])
|
])
|
||||||
await httpPut(grant.url, tmp)
|
await httpPut(grant.url, tmp)
|
||||||
core.info(`Uploaded branch delta for '${plan.refKey}'`)
|
core.info(`Uploaded branch delta for '${plan.refKey}'`)
|
||||||
|
|
@ -286,19 +290,16 @@ async function uploadBranchDelta(settings: IGitSourceSettings): Promise<void> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// `^refname` for every seeded base ref — the exclusion set that makes the delta bundle
|
// Whether any base ref was seeded — the guard that keeps the delta base-relative. The
|
||||||
// base-relative (and therefore order-free).
|
// base is excluded by glob (see uploadBranchDelta), so we only need existence here.
|
||||||
async function baseRefExcludes(repoPath: string): Promise<string[]> {
|
async function hasBaseRefs(repoPath: string): Promise<boolean> {
|
||||||
let out = ''
|
let out = ''
|
||||||
await exec.exec(
|
await exec.exec(
|
||||||
'git',
|
'git',
|
||||||
['-C', repoPath, 'for-each-ref', '--format=^%(refname)', BASE_REFNS],
|
['-C', repoPath, 'for-each-ref', '--count=1', '--format=1', BASE_REFNS],
|
||||||
{silent: true, listeners: {stdout: (d: Buffer) => (out += d.toString())}}
|
{silent: true, listeners: {stdout: (d: Buffer) => (out += d.toString())}}
|
||||||
)
|
)
|
||||||
return out
|
return out.trim().length > 0
|
||||||
.split('\n')
|
|
||||||
.map(s => s.trim())
|
|
||||||
.filter(Boolean)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadTo(url: string, dest: string): Promise<void> {
|
async function downloadTo(url: string, dest: string): Promise<void> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue