From 4259078bf6b275405a3534f23cfb5f73d51341c5 Mon Sep 17 00:00:00 2001 From: mitchell Date: Wed, 11 Sep 2024 17:08:27 -0400 Subject: [PATCH] Update activestate.yaml with any buildscript checkout info changes. --- internal/runbits/buildscript/file.go | 13 ++++++++++++- pkg/checkoutinfo/checkoutinfo.go | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/runbits/buildscript/file.go b/internal/runbits/buildscript/file.go index e5cecf8f1f..b950abcbbc 100644 --- a/internal/runbits/buildscript/file.go +++ b/internal/runbits/buildscript/file.go @@ -37,7 +37,18 @@ func ScriptFromFile(path string) (*buildscript.BuildScript, error) { } return nil, errs.Wrap(err, "Could not read build script from file") } - return buildscript.Unmarshal(data) + + script, err := buildscript.Unmarshal(data) + if err != nil { + return nil, errs.Wrap(err, "Could not unmarshal build script") + } + + err = checkoutinfo.UpdateProject(script, path) + if err != nil { + return nil, errs.Wrap(err, "Could not update project file") + } + + return script, nil } func Initialize(path, owner, project, branch string, auth *authentication.Auth) error { diff --git a/pkg/checkoutinfo/checkoutinfo.go b/pkg/checkoutinfo/checkoutinfo.go index 2788fff471..62b3bef482 100644 --- a/pkg/checkoutinfo/checkoutinfo.go +++ b/pkg/checkoutinfo/checkoutinfo.go @@ -112,3 +112,18 @@ func updateBuildScript() error { return nil } + +func UpdateProject(script *buildscript.BuildScript, dir string) error { + err := setupProject(dir) + if err != nil { + return errs.Wrap(err, "Could not setup project") + } + + proj.Source().Project = script.ProjectURL() + err = proj.Source().Save(nil) + if err != nil { + return errs.Wrap(err, "Could not update project") + } + + return nil +}