This commit is contained in:
Andrew Klotz 2026-08-06 23:45:37 +00:00 committed by GitHub
commit 7355f96c61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 36 additions and 0 deletions

View File

@ -136,6 +136,16 @@ jobs:
run: __test__/verify-sparse-checkout-non-cone-mode.sh run: __test__/verify-sparse-checkout-non-cone-mode.sh
# LFS # LFS
# First check out without LFS so the reused worktree is left holding LFS
# pointer files; the `lfs: true` checkout below must then materialize them
# rather than leave the stale pointers in place (#270).
- name: Checkout LFS pointers (reused worktree setup)
uses: ./
with:
repository: actions/checkout # hardcoded, otherwise doesn't work from a fork
ref: test-data/v2/lfs
path: lfs
lfs: false
- name: Checkout LFS - name: Checkout LFS
uses: ./ uses: ./
with: with:

View File

@ -1065,6 +1065,7 @@ async function setup(testName: string): Promise<void> {
getWorkingDirectory: jest.fn(() => workspace), getWorkingDirectory: jest.fn(() => workspace),
init: jest.fn(), init: jest.fn(),
isDetached: jest.fn(), isDetached: jest.fn(),
lfsCheckout: jest.fn(),
lfsFetch: jest.fn(), lfsFetch: jest.fn(),
lfsInstall: jest.fn(), lfsInstall: jest.fn(),
log1: jest.fn(), log1: jest.fn(),

View File

@ -497,6 +497,7 @@ async function setup(testName: string): Promise<void> {
getWorkingDirectory: jest.fn(() => repositoryPath), getWorkingDirectory: jest.fn(() => repositoryPath),
init: jest.fn(), init: jest.fn(),
isDetached: jest.fn(), isDetached: jest.fn(),
lfsCheckout: jest.fn(),
lfsFetch: jest.fn(), lfsFetch: jest.fn(),
lfsInstall: jest.fn(), lfsInstall: jest.fn(),
log1: jest.fn(), log1: jest.fn(),

View File

@ -9,3 +9,8 @@ if [ ! -f "./lfs/lfs-file.bin" ]; then
echo "Expected lfs file does not exist" echo "Expected lfs file does not exist"
exit 1 exit 1
fi fi
if head -n 1 "./lfs/lfs-file.bin" | grep -q "git-lfs.github.com/spec"; then
echo "Expected lfs file to be materialized, but it is still an LFS pointer"
exit 1
fi

8
dist/index.js vendored
View File

@ -35816,6 +35816,9 @@ class GitCommandManager {
const output = await this.execGit(['rev-parse', '--symbolic-full-name', '--verify', '--quiet', 'HEAD'], true); const output = await this.execGit(['rev-parse', '--symbolic-full-name', '--verify', '--quiet', 'HEAD'], true);
return !output.stdout.trim().startsWith('refs/heads/'); return !output.stdout.trim().startsWith('refs/heads/');
} }
async lfsCheckout() {
await this.execGit(['lfs', 'checkout']);
}
async lfsFetch(ref) { async lfsFetch(ref) {
const args = ['lfs', 'fetch', 'origin', ref]; const args = ['lfs', 'fetch', 'origin', ref];
const that = this; const that = this;
@ -41879,6 +41882,11 @@ async function getSource(settings) {
startGroup('Checking out the ref'); startGroup('Checking out the ref');
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint); await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint);
endGroup(); endGroup();
if (settings.lfs && !settings.sparseCheckout) {
startGroup('Checking out LFS objects');
await git.lfsCheckout();
endGroup();
}
// Submodules // Submodules
if (settings.submodules) { if (settings.submodules) {
// Temporarily override global config // Temporarily override global config

View File

@ -45,6 +45,7 @@ export interface IGitCommandManager {
getWorkingDirectory(): string getWorkingDirectory(): string
init(objectFormat?: string): Promise<void> init(objectFormat?: string): Promise<void>
isDetached(): Promise<boolean> isDetached(): Promise<boolean>
lfsCheckout(): Promise<void>
lfsFetch(ref: string): Promise<void> lfsFetch(ref: string): Promise<void>
lfsInstall(): Promise<void> lfsInstall(): Promise<void>
log1(format?: string): Promise<string> log1(format?: string): Promise<string>
@ -383,6 +384,10 @@ class GitCommandManager {
return !output.stdout.trim().startsWith('refs/heads/') return !output.stdout.trim().startsWith('refs/heads/')
} }
async lfsCheckout(): Promise<void> {
await this.execGit(['lfs', 'checkout'])
}
async lfsFetch(ref: string): Promise<void> { async lfsFetch(ref: string): Promise<void> {
const args = ['lfs', 'fetch', 'origin', ref] const args = ['lfs', 'fetch', 'origin', ref]

View File

@ -271,6 +271,12 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint) await git.checkout(checkoutInfo.ref, checkoutInfo.startPoint)
core.endGroup() core.endGroup()
if (settings.lfs && !settings.sparseCheckout) {
core.startGroup('Checking out LFS objects')
await git.lfsCheckout()
core.endGroup()
}
// Submodules // Submodules
if (settings.submodules) { if (settings.submodules) {
// Temporarily override global config // Temporarily override global config