From 4f6e0dc8ce0de65d3a8f6cfce5fd58f5b6bcaea5 Mon Sep 17 00:00:00 2001 From: dawn Date: Mon, 22 Jun 2026 17:54:06 +0300 Subject: [PATCH] spindle,workflow: fetch the repo with tags Signed-off-by: dawn --- api/tangled/cbor_gen.go | 36 ++++++++++++++++++++++++++++++++- api/tangled/tangledpipeline.go | 1 + flake.nix | 2 +- lexicons/pipeline/pipeline.json | 6 +++++- spindle/models/clone.go | 5 +++++ workflow/compile.go | 21 +++++++++++-------- workflow/def.go | 10 +++++---- 7 files changed, 66 insertions(+), 15 deletions(-) diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go index 1c7a5ea7..ad826b28 100644 --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -5074,7 +5074,7 @@ func (t *Pipeline_CloneOpts) MarshalCBOR(w io.Writer) error { cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{163}); err != nil { + if _, err := cw.Write([]byte{164}); err != nil { return err } @@ -5094,6 +5094,22 @@ func (t *Pipeline_CloneOpts) MarshalCBOR(w io.Writer) error { return err } + // t.Tags (bool) (bool) + if len("tags") > 1000000 { + return xerrors.Errorf("Value in field \"tags\" was too long") + } + + if err := cw.WriteMajorTypeHeader(cbg.MajTextString, uint64(len("tags"))); err != nil { + return err + } + if _, err := cw.WriteString(string("tags")); err != nil { + return err + } + + if err := cbg.WriteBool(w, t.Tags); err != nil { + return err + } + // t.Depth (int64) (int64) if len("depth") > 1000000 { return xerrors.Errorf("Value in field \"depth\" was too long") @@ -5193,6 +5209,24 @@ func (t *Pipeline_CloneOpts) UnmarshalCBOR(r io.Reader) (err error) { default: return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) } + // t.Tags (bool) (bool) + case "tags": + + maj, extra, err = cr.ReadHeader() + if err != nil { + return err + } + if maj != cbg.MajOther { + return fmt.Errorf("booleans must be major type 7") + } + switch extra { + case 20: + t.Tags = false + case 21: + t.Tags = true + default: + return fmt.Errorf("booleans are either major type 7, value 20 or 21 (got %d)", extra) + } // t.Depth (int64) (int64) case "depth": { diff --git a/api/tangled/tangledpipeline.go b/api/tangled/tangledpipeline.go index 56627464..b0ab4a1b 100644 --- a/api/tangled/tangledpipeline.go +++ b/api/tangled/tangledpipeline.go @@ -27,6 +27,7 @@ type Pipeline_CloneOpts struct { Depth int64 `json:"depth" cborgen:"depth"` Skip bool `json:"skip" cborgen:"skip"` Submodules bool `json:"submodules" cborgen:"submodules"` + Tags bool `json:"tags" cborgen:"tags"` } // Pipeline_ManualTriggerData is a "manualTriggerData" in the sh.tangled.pipeline schema. diff --git a/flake.nix b/flake.nix index 5b6afa67..05d218bc 100644 --- a/flake.nix +++ b/flake.nix @@ -482,7 +482,7 @@ find api/tangled/*.go -not -name "cbor_gen.go" -exec \ sed -i '/^func.*\(MarshalCBOR\|UnmarshalCBOR\)/,/^}/ s/^/\/\/ /' {} + ${pkgs.gotools}/bin/goimports -w api/tangled/* - go run ./cmd/cborgen/ + CGO_ENABLED=0 go run ./cmd/cborgen/ lexgen --build-file lexicon-build-config.json lexicons rm api/tangled/*.bak ''; diff --git a/lexicons/pipeline/pipeline.json b/lexicons/pipeline/pipeline.json index 3e0f9323..5d347f41 100644 --- a/lexicons/pipeline/pipeline.json +++ b/lexicons/pipeline/pipeline.json @@ -178,7 +178,8 @@ "required": [ "skip", "depth", - "submodules" + "submodules", + "tags" ], "properties": { "skip": { @@ -189,6 +190,9 @@ }, "submodules": { "type": "boolean" + }, + "tags": { + "type": "boolean" } } }, diff --git a/spindle/models/clone.go b/spindle/models/clone.go index e95575df..f9e0b38e 100644 --- a/spindle/models/clone.go +++ b/spindle/models/clone.go @@ -140,6 +140,11 @@ func buildFetchArgs(clone tangled.Pipeline_CloneOpts, sha string) []string { args = append(args, "--recurse-submodules=yes") } + // Add tags if requested + if clone.Tags { + args = append(args, "--tags") + } + // Add remote and SHA args = append(args, "origin") if sha != "" { diff --git a/workflow/compile.go b/workflow/compile.go index 55c7f20a..61bd6e55 100644 --- a/workflow/compile.go +++ b/workflow/compile.go @@ -151,19 +151,24 @@ func (compiler *Compiler) compileWorkflow(w Workflow) *tangled.Pipeline_Workflow } func (compiler *Compiler) analyzeCloneOptions(w Workflow) { - if w.CloneOpts.Skip && w.CloneOpts.IncludeSubmodules { - compiler.Diagnostics.AddWarning( - w.Name, - InvalidConfiguration, - "cannot apply `clone.skip` and `clone.submodules`", - ) + if !w.CloneOpts.Skip { + return } - if w.CloneOpts.Skip && w.CloneOpts.Depth > 0 { + warn := func(key string) { compiler.Diagnostics.AddWarning( w.Name, InvalidConfiguration, - "cannot apply `clone.skip` and `clone.depth`", + fmt.Sprintf("cannot apply `clone.skip` and `clone.%s`", key), ) } + if w.CloneOpts.Tags != nil { + warn("tags") + } + if w.CloneOpts.IncludeSubmodules != nil { + warn("submodules") + } + if w.CloneOpts.Depth > 0 { + warn("depth") + } } diff --git a/workflow/def.go b/workflow/def.go index 030f3d38..de4a550b 100644 --- a/workflow/def.go +++ b/workflow/def.go @@ -40,9 +40,10 @@ type ( } CloneOpts struct { - Skip bool `yaml:"skip"` - Depth int `yaml:"depth"` - IncludeSubmodules bool `yaml:"submodules"` + Skip bool `yaml:"skip"` + Depth int `yaml:"depth"` + IncludeSubmodules *bool `yaml:"submodules"` + Tags *bool `yaml:"tags"` } StringList []string @@ -237,6 +238,7 @@ func (c CloneOpts) AsRecord() tangled.Pipeline_CloneOpts { return tangled.Pipeline_CloneOpts{ Depth: int64(c.Depth), Skip: c.Skip, - Submodules: c.IncludeSubmodules, + Submodules: c.IncludeSubmodules == nil || *c.IncludeSubmodules, + Tags: c.Tags == nil || *c.Tags, } } -- 2.51.2