-
Notifications
You must be signed in to change notification settings - Fork 3
Add lfs to checkout #78
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
Open
stephanieatte
wants to merge
8
commits into
main
Choose a base branch
from
SUP-6527/add-lfs-to-checkout
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1cc109b
Add Checkout type
petetomasik 4343eda
Wire Checkout into Pipeline and CommandStep
petetomasik c3d8ce8
Sign checkout field on command steps
petetomasik 02b91f7
Document checkout in README
petetomasik c3bee74
Add Depth field to Checkout
JoeColeman95 f0aff7b
Update README.md to reflect changes
JoeColeman95 771c524
Add LFS bool field to Checkout struct
stephanieatte bb17e3f
Change LFS field from bool to *bool to support tristate
stephanieatte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| package pipeline | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
|
|
||
| "github.com/buildkite/go-pipeline/ordered" | ||
| ) | ||
|
|
||
| var _ interface { | ||
| json.Marshaler | ||
| ordered.Unmarshaler | ||
| selfInterpolater | ||
| } = (*Checkout)(nil) | ||
|
|
||
| var errUnsupportedCheckoutType = fmt.Errorf("unsupported type for checkout") | ||
|
|
||
| // Checkout models the checkout configuration for a pipeline or command step. | ||
| type Checkout struct { | ||
| // Skip is *bool to preserve the tristate distinction (true / false / absent). | ||
| // `bool` plus `omitempty` would collapse `skip: false` and an absent `skip` | ||
| // field into the same empty output. | ||
| Skip *bool `yaml:"skip,omitempty"` | ||
|
|
||
| // Depth as *int to allow integers and not set | ||
| Depth *int `yaml:"depth,omitempty"` | ||
|
|
||
| // LFS enables Git LFS when true. Defaults to false (zero value). | ||
| LFS bool `json:"lfs,omitempty" yaml:"lfs,omitempty"` | ||
|
|
||
| // RemainingFields stores any other top-level mapping items so they at least | ||
| // survive an unmarshal-marshal round-trip. | ||
| RemainingFields map[string]any `yaml:",inline"` | ||
| } | ||
|
|
||
| // MarshalJSON marshals the checkout to JSON. Special handling is needed because | ||
| // yaml.v3 has "inline" but encoding/json has no concept of it. | ||
| func (c *Checkout) MarshalJSON() ([]byte, error) { | ||
| return inlineFriendlyMarshalJSON(c) | ||
| } | ||
|
|
||
| // IsEmpty reports whether the checkout is empty, used by signing. | ||
| func (c *Checkout) IsEmpty() bool { | ||
| return c == nil || (c.Skip == nil && c.Depth == nil && !c.LFS && len(c.RemainingFields) == 0) | ||
| } | ||
|
|
||
| // UnmarshalOrdered unmarshals a Checkout from an ordered map. Bool inputs are | ||
| // rejected; see the error message for the supported form. | ||
| func (c *Checkout) UnmarshalOrdered(o any) error { | ||
| switch v := o.(type) { | ||
| case bool: | ||
| return fmt.Errorf("unmarshaling checkout: bool is not a valid value; use checkout.skip (e.g. checkout: { skip: %t }) instead", v) | ||
|
|
||
| case *ordered.MapSA: | ||
| type wrappedCheckout Checkout | ||
| if err := ordered.Unmarshal(o, (*wrappedCheckout)(c)); err != nil { | ||
| return fmt.Errorf("unmarshaling checkout: %w", err) | ||
| } | ||
| return nil | ||
|
|
||
| default: | ||
| return fmt.Errorf("unmarshaling checkout: %w: got %T, want a mapping with checkout.skip and other fields", errUnsupportedCheckoutType, o) | ||
| } | ||
| } | ||
|
|
||
| // interpolate is a no-op today: Skip is *bool, and RemainingFields is not | ||
| // traversed. | ||
| func (c *Checkout) interpolate(stringTransformer) error { | ||
| return nil | ||
| } | ||
|
|
||
| // mergeFrom merges parent values into c. Child wins per top-level key; | ||
| // parent contributes only keys the child does not set. | ||
| func (c *Checkout) mergeFrom(parent *Checkout) { | ||
| if c == nil || parent == nil { | ||
| return | ||
| } | ||
|
|
||
| if c.Skip == nil && parent.Skip != nil { | ||
| v := *parent.Skip | ||
| c.Skip = &v | ||
| } | ||
|
|
||
| if c.Depth == nil && parent.Depth != nil { | ||
| v := *parent.Depth | ||
| c.Depth = &v | ||
| } | ||
|
|
||
| if !c.LFS && parent.LFS { | ||
| c.LFS = parent.LFS | ||
| } | ||
|
|
||
| if len(parent.RemainingFields) == 0 { | ||
| return | ||
| } | ||
| if c.RemainingFields == nil { | ||
| c.RemainingFields = make(map[string]any, len(parent.RemainingFields)) | ||
| } | ||
| for k, pv := range parent.RemainingFields { | ||
| if _, ok := c.RemainingFields[k]; ok { | ||
| continue | ||
| } | ||
| c.RemainingFields[k] = pv | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.