Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: update makefile to set plugins branch ref #4421

Merged
merged 4 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PWD := $(shell pwd)
PARENT_DIR := $(shell dirname $(PWD))
VERSION ?= $(shell ../scripts/get-version.sh)
PLUGINS_BRANCH ?= master
OS ?= linux darwin windows
OUTPUT_DIR := _output

Expand All @@ -27,7 +28,7 @@ endif
.PHONY: build
build: export CGO_ENABLED=0
build:
gox -ldflags '-X github.com/hasura/graphql-engine/cli/version.BuildVersion=$(VERSION) -s -w -extldflags "-static"' \
gox -ldflags '-X github.com/hasura/graphql-engine/cli/version.BuildVersion=$(VERSION) -X github.com/hasura/graphql-engine/cli/plugins.IndexBranchRef=$(PLUGINS_BRANCH) -s -w -extldflags "-static"' \
-rebuild \
-os="$(OS)" \
-arch="amd64" \
Expand Down
5 changes: 4 additions & 1 deletion cli/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var (
ErrVersionNotAvailable = errors.New("plugin version is not available")
)

// IndexBranchRef - branch to be used for index
var IndexBranchRef = "master"

const (
indexURI string = "https://github.com/hasura/cli-plugins-index.git"
)
Expand All @@ -56,7 +59,7 @@ func New(base string) *Config {
p := paths.NewPaths(base)
return &Config{
Paths: p,
Repo: util.NewGitUtil(indexURI, p.IndexPath(), "multiple-version"),
Repo: util.NewGitUtil(indexURI, p.IndexPath(), IndexBranchRef),
}
}

Expand Down
18 changes: 14 additions & 4 deletions cli/util/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"

"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/config"
"gopkg.in/src-d/go-git.v4/plumbing"
)

Expand Down Expand Up @@ -77,21 +78,30 @@ func (g *GitUtil) updateAndCleanUntracked() error {
if err != nil {
return err
}
err = repo.Fetch(&git.FetchOptions{})
err = repo.Fetch(&git.FetchOptions{
RefSpecs: []config.RefSpec{"refs/*:refs/*"},
})
if err != nil && err != git.NoErrAlreadyUpToDate {
return err
}
wt, err := repo.Worktree()
if err != nil {
return err
}
err = wt.Pull(&git.PullOptions{})
err = wt.Checkout(&git.CheckoutOptions{
Branch: g.ReferenceName,
})
if err != nil {
return err
}
err = wt.Pull(&git.PullOptions{
ReferenceName: g.ReferenceName,
})
if err != nil && err != git.NoErrAlreadyUpToDate {
return err
}
err = wt.Reset(&git.ResetOptions{
Commit: plumbing.ZeroHash,
Mode: git.HardReset,
Mode: git.HardReset,
})
if err != nil {
return err
Expand Down