From df1c7a11b685db9b502ba7ec9c3c1e152f655982 Mon Sep 17 00:00:00 2001 From: nicholasSSUSE Date: Wed, 15 Jan 2025 15:50:56 -0300 Subject: [PATCH 1/2] enabling make validate to a specific package for debugging --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index fad4c1e8..060da7df 100644 --- a/main.go +++ b/main.go @@ -540,7 +540,6 @@ func validateRepo(c *cli.Context) { logrus.Fatalf("cannot specify both local and remote validation") } - CurrentPackage = "" // Validate always runs on all packages chartsScriptOptions := parseScriptOptions() logrus.Infof("Checking if Git is clean") From 1876b587698cef5e829bab55891d0f9779f53ae3 Mon Sep 17 00:00:00 2001 From: nicholasSSUSE Date: Wed, 15 Jan 2025 16:37:07 -0300 Subject: [PATCH 2/2] fixing status-lifecycle for current release branch bug --- pkg/git/git.go | 19 +++++++++++++++++++ pkg/lifecycle/status.go | 16 ++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/pkg/git/git.go b/pkg/git/git.go index 4c1d745b..fbf6c99d 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -133,6 +133,25 @@ func (g *Git) getGitRemotes() (map[string]string, error) { return remotes, nil } +func (g *Git) FetchAndPullBranch(branch string) error { + logrus.Infof("Fetching and pulling branch %s", branch) + remote := g.Remotes["https://github.com/rancher/charts"] + + cmd := exec.Command("git", "-C", g.Dir, "fetch", remote, branch) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + if err := cmd.Run(); err != nil { + return err + } + + cmd = exec.Command("git", "-C", g.Dir, "pull", remote, branch) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + + return cmd.Run() +} + // FetchAndCheckoutBranch fetches and checks out a branch func (g *Git) FetchAndCheckoutBranch(branch string) error { logrus.Infof("Fetching and checking out at: %s", g.Branch) diff --git a/pkg/lifecycle/status.go b/pkg/lifecycle/status.go index 75b36043..9405ef2f 100644 --- a/pkg/lifecycle/status.go +++ b/pkg/lifecycle/status.go @@ -206,10 +206,18 @@ func (s *Status) getProdAndDevAssetsFromGit(git *git.Git) (map[string][]Asset, m rootFs := filesystem.GetFilesystem(s.ld.Git.Dir) helmIndexPath := filesystem.GetAbsPath(rootFs, path.RepositoryHelmIndexFile) - // Fetch and checkout to the production branch - err := git.FetchAndCheckoutBranch(s.ld.VR.ProdBranch) - if err != nil { - return nil, nil, err + if s.ld.Git.Branch == s.ld.VR.ProdBranch { + // Fetch and checkout to the production branch + err := git.FetchAndPullBranch(s.ld.VR.ProdBranch) + if err != nil { + return nil, nil, err + } + } else { + // Fetch and checkout to the production branch + err := git.FetchAndCheckoutBranch(s.ld.VR.ProdBranch) + if err != nil { + return nil, nil, err + } } // Get the map for the released assets versions on the production branch