Skip to content

Commit

Permalink
fix: missing git checkout
Browse files Browse the repository at this point in the history
  • Loading branch information
deimosfr committed Jul 9, 2021
1 parent 6cf3fbc commit 588d58d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ charts:
# When using a git repo, chart_path is mandatory, you need to specify the chart folder path
chart_path: /charts/pleco
dest: custom
version: v0.8.4
# Set git reference
version: 5e05faddb0fde1f5ddd822c3d3ba72925f094e67

repos:
# Stable is the default one
Expand Down Expand Up @@ -108,7 +109,7 @@ $ helm-freeze sync
-> stable/elasticsearch-curator 2.1.5
-> aws/aws-node-termination-handler 0.8.0
-> aws/aws-vpc-cni 1.0.9
-> git/pleco 0.8.4
-> git/pleco 5e05faddb0fde1f5ddd822c3d3ba72925f094e67
Sync succeed!
```
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var versionCmd = &cobra.Command{
}

func GetCurrentVersion() string {
return "0.4.0" // ci-version-check
return "0.4.1" // ci-version-check
}

func init() {
Expand Down
20 changes: 17 additions & 3 deletions exec/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/Qovery/helm-freeze/cfg"
"github.com/Qovery/helm-freeze/util"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/otiai10/copy"
"os"
"os/exec"
Expand Down Expand Up @@ -208,7 +209,7 @@ func getGitChart(chart map[string]string, destinations map[string]string, repos
}
}

clonedRepoDir, err := gitClone(chartUrl)
clonedRepoDir, err := gitClone(chartUrl, chart["version"])
if err != nil {
if chartExists {
// restore old chart on failure
Expand Down Expand Up @@ -238,19 +239,32 @@ func getGitChart(chart map[string]string, destinations map[string]string, repos
return nil
}

func gitClone(gitUrl string) (string, error) {
func gitClone(gitUrl string, commitSha string) (string, error) {
// create tmp dir to clone to this dir
tmpDir, err := util.MkdirTemp()
if err != nil {
return "", err
}
_, err = git.PlainClone(tmpDir, false, &git.CloneOptions{
r, err := git.PlainClone(tmpDir, false, &git.CloneOptions{
URL: gitUrl,
})
if err != nil {
return "", err
}

w, err := r.Worktree()
if err != nil {
return "", err
}

// git checkout
err = w.Checkout(&git.CheckoutOptions{
Hash: plumbing.NewHash(commitSha),
})
if err != nil {
return "", err
}

return tmpDir, nil
}

Expand Down

0 comments on commit 588d58d

Please sign in to comment.