From 4f6e0dc8ce0de65d3a8f6cfce5fd58f5b6bcaea5 Mon Sep 17 00:00:00 2001 From: dawn Date: Mon, 22 Jun 2026 14:54:06 +0000 Subject: [PATCH] spindle,workflow: fetch the repo with tags Signed-off-by: dawn --- flake.nix | 2 +- workflow/compile.go | 21 +++++++++++++-------- workflow/def.go | 10 ++++++---- api/tangled/cbor_gen.go | 36 +++++++++++++++++++++++++++++++++++- api/tangled/tangledpipeline.go | 1 + lexicons/pipeline/pipeline.json | 6 +++++- spindle/models/clone.go | 5 +++++ 7 file(s) changed, 66 insertion(s)(+), 15 deletion(s)(-) diff --git a/flake.nix b/flake.nix --- 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/workflow/compile.go b/workflow/compile.go --- a/workflow/compile.go +++ b/workflow/compile.go @@ -151,19 +151,24 @@ } 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 --- a/workflow/def.go +++ b/workflow/def.go @@ -40,9 +40,10 @@ } 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 @@ 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, } } diff --git a/api/tangled/cbor_gen.go b/api/tangled/cbor_gen.go --- a/api/tangled/cbor_gen.go +++ b/api/tangled/cbor_gen.go @@ -5074,7 +5074,7 @@ cw := cbg.NewCborWriter(w) - if _, err := cw.Write([]byte{163}); err != nil { + if _, err := cw.Write([]byte{164}); err != nil { return err } @@ -5091,6 +5091,22 @@ } if err := cbg.WriteBool(w, t.Skip); err != nil { + 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 } @@ -5190,6 +5206,24 @@ t.Skip = false case 21: t.Skip = true + 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) } diff --git a/api/tangled/tangledpipeline.go b/api/tangled/tangledpipeline.go --- a/api/tangled/tangledpipeline.go +++ b/api/tangled/tangledpipeline.go @@ -27,6 +27,7 @@ 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/lexicons/pipeline/pipeline.json b/lexicons/pipeline/pipeline.json --- a/lexicons/pipeline/pipeline.json +++ b/lexicons/pipeline/pipeline.json @@ -178,7 +178,8 @@ "required": [ "skip", "depth", - "submodules" + "submodules", + "tags" ], "properties": { "skip": { @@ -188,6 +189,9 @@ "type": "integer" }, "submodules": { + "type": "boolean" + }, + "tags": { "type": "boolean" } } diff --git a/spindle/models/clone.go b/spindle/models/clone.go --- a/spindle/models/clone.go +++ b/spindle/models/clone.go @@ -140,6 +140,11 @@ 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 != "" { -- tangled.sh