-
Notifications
You must be signed in to change notification settings - Fork 359
feat: add support for GIT LFS checkout #3909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7020d2b
c13ebbd
b609aad
5a4e6d6
6e49454
90cf458
9a649dd
caa99c8
ec59818
9df1a63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "os/exec" | ||
| "path/filepath" | ||
| "runtime" | ||
| "slices" | ||
|
|
@@ -262,6 +263,14 @@ func (e *Executor) checkout(ctx context.Context) error { | |
| break | ||
| } | ||
|
|
||
| // Fail fast before any git work if git-lfs is required but missing. | ||
| // This operation only handles default checkout behavior, so it's possible for a custom checkout hook to require git-lfs but not have this check. That's a bit unfortunate, but we can add it to custom hooks later if needed. | ||
| if e.GitLFSEnabled { | ||
| if _, err := exec.LookPath("git-lfs"); err != nil { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: |
||
| return fmt.Errorf("BUILDKITE_GIT_LFS_ENABLED=true but git-lfs binary is not found on PATH: %w", err) | ||
| } | ||
| } | ||
|
|
||
| maxAttempts := e.CheckoutAttempts | ||
| if maxAttempts <= 0 { | ||
| maxAttempts = 6 | ||
|
|
@@ -964,6 +973,15 @@ func (e *Executor) defaultCheckoutPhase(ctx context.Context) (retErr error) { | |
| return fmt.Errorf("cleaning git repository: %w", err) | ||
| } | ||
|
|
||
| // Install LFS filter before fetch so the filter is registered before any | ||
| // network operation, following the conventional git-lfs setup order. | ||
| if e.GitLFSEnabled { | ||
| e.shell.Commentf("Installing Git LFS filter") | ||
| if err := e.shell.Command("git", "lfs", "install", "--local").Run(ctx); err != nil { | ||
| return fmt.Errorf("installing git lfs filter: %w", err) | ||
| } | ||
| } | ||
|
|
||
| if err := e.fetchSource(ctx); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -1081,6 +1099,15 @@ func (e *Executor) defaultCheckoutPhase(ctx context.Context) (retErr error) { | |
| } | ||
| } | ||
|
|
||
| if e.GitLFSEnabled { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocking: |
||
| if err := gitLFSFetchCheckout(ctx, gitLFSFetchCheckoutArgs{ | ||
| Shell: e.shell, | ||
| Retry: true, | ||
| }); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| // Git clean after checkout. We need to do this because submodules could have | ||
| // changed in between the last checkout and this one. A double clean is the only | ||
| // good solution to this problem that we've found | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.