Skip to content

Commit

Permalink
Merge pull request #158 from nicholasSUSE/bug-fixes-1.3.3
Browse files Browse the repository at this point in the history
Bug fixes 1.3.3
  • Loading branch information
nicholasSUSE authored Jan 15, 2025
2 parents 9a3bd00 + 1876b58 commit 9e42f7e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
19 changes: 19 additions & 0 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions pkg/lifecycle/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e42f7e

Please sign in to comment.