diff --git a/Dockerfile_c b/Dockerfile_c index 00e387b..c958028 100644 --- a/Dockerfile_c +++ b/Dockerfile_c @@ -31,9 +31,9 @@ RUN apt-get -qq update && apt-get install -y cmake build-essential pkg-config op make && make install && \ cd / && \ rm -rf libssh2-1.4.2 && \ - curl -L -o v0.22.0.tar.gz -z v0.22.0.tar.gz https://github.com/libgit2/libgit2/archive/v0.22.0.tar.gz && \ - tar xzvf v0.22.0.tar.gz && \ - cd libgit2-0.22.0 && \ + curl -L -o v0.24.1.tar.gz -z v0.24.1.tar.gz https://github.com/libgit2/libgit2/archive/v0.24.1.tar.gz && \ + tar xzvf v0.24.1.tar.gz && \ + cd libgit2-0.24.1 && \ pwd && \ mkdir build && \ cd build && \ diff --git a/credentials/credentials.go b/credentials/credentials.go index aebd3a8..55bf83a 100644 --- a/credentials/credentials.go +++ b/credentials/credentials.go @@ -20,7 +20,7 @@ import ( "github.com/cpg1111/maestro/config" prompt "github.com/segmentio/go-prompt" - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) // RawCredentials is a struct for any credentials diff --git a/pipeline/build.go b/pipeline/build.go index 74e508f..d55c639 100644 --- a/pipeline/build.go +++ b/pipeline/build.go @@ -16,7 +16,7 @@ package pipeline import ( "log" - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) func build(srv *DepService, index string, done chan string, errChan chan error, shouldDeploy *bool) { diff --git a/pipeline/clone.go b/pipeline/clone.go index 420660d..b33e9a5 100644 --- a/pipeline/clone.go +++ b/pipeline/clone.go @@ -17,14 +17,13 @@ import ( "fmt" "log" "os" - "time" "github.com/cpg1111/maestro/config" "github.com/cpg1111/maestro/credentials" "github.com/cpg1111/maestro/util" pb "gopkg.in/cheggaaa/pb.v1" - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) // Project is a struct for the Project in the pipeline @@ -53,7 +52,6 @@ var ( progbar *pb.ProgressBar received uint hasFinished = false - done = make(chan bool) ) func handleProgress(stats git.TransferProgress) git.ErrorCode { @@ -67,13 +65,15 @@ func handleProgress(stats git.TransferProgress) git.ErrorCode { received = stats.ReceivedObjects if (int)(received) == (int)(stats.TotalObjects) && !hasFinished { hasFinished = true - time.Sleep(time.Second) - done <- true - return git.ErrOk + return handleComplete(git.RemoteCompletionDownload) } return git.ErrOk } +func handleComplete(complete git.RemoteCompletion) git.ErrorCode { + return git.ErrOk +} + // New returns a new instance of a pipeline project func New(conf *config.Config, creds *credentials.RawCredentials, clonePath, branch, last, curr string) *Project { var absPath string @@ -91,14 +91,18 @@ func New(conf *config.Config, creds *credentials.RawCredentials, clonePath, bran panic(cwdErr) } gitCreds := creds.ToGitCredentials() - cloneOpts := &git.CloneOptions{ - RemoteCallbacks: &git.RemoteCallbacks{ + fetchOpts := &git.FetchOptions{ + RemoteCallbacks: git.RemoteCallbacks{ CredentialsCallback: credCB(&gitCreds), CertificateCheckCallback: certCheckCB, TransferProgressCallback: handleProgress, + CompletionCallback: handleComplete, }, + } + cloneOpts := &git.CloneOptions{ + FetchOptions: fetchOpts, CheckoutOpts: &git.CheckoutOpts{ - Strategy: git.CheckoutSafeCreate, + Strategy: git.CheckoutSafe, }, Bare: false, CheckoutBranch: branch, @@ -118,40 +122,11 @@ func New(conf *config.Config, creds *credentials.RawCredentials, clonePath, bran // Clone clones a git repo func (p *Project) Clone() (resRepo *git.Repository, resErr error) { log.Println("Cloning Repo...") - repoChan := make(chan *git.Repository) - errChan := make(chan error) - go func() { - repo, repoErr := git.Clone(p.conf.RepoURL, fmt.Sprintf("%s/", p.clonePath), p.CloneOpts) - repoChan <- repo - errChan <- repoErr - }() - var doneMsg bool - for { - select { - case resRepo = <-repoChan: - if resRepo != nil && doneMsg { - cdErr := os.Chdir(p.ABSPath) - if cdErr != nil { - log.Fatal(cdErr) - } - return - } - case resErr = <-errChan: - if resErr != nil { - panic(resErr) - } - case doneMsg = <-done: - if resRepo != nil && doneMsg { - cdErr := os.Chdir(p.ABSPath) - if cdErr != nil { - log.Fatal(cdErr) - } - return - } - } - } + resRepo, resErr = git.Clone(p.conf.RepoURL, fmt.Sprintf("%s/", p.clonePath), p.CloneOpts) + return } +// Checkout checks out the repo to the current commit or HEAD of the branch func (p *Project) Checkout(repo *git.Repository, commit string) error { tree, treeErr := util.CommitToTree(repo, commit) if treeErr != nil { diff --git a/pipeline/service.go b/pipeline/service.go index c7dcb85..ea1aeb7 100644 --- a/pipeline/service.go +++ b/pipeline/service.go @@ -25,7 +25,7 @@ import ( "github.com/cpg1111/maestro/credentials" "github.com/cpg1111/maestro/util" - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) // Service is a struct for services in the pipeline diff --git a/pipeline/tree.go b/pipeline/tree.go index 25cb0e7..e2a6fa4 100644 --- a/pipeline/tree.go +++ b/pipeline/tree.go @@ -17,7 +17,7 @@ import ( "errors" "log" - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) // DepTree is a dependency tree to determine whether or not to build services diff --git a/util/commit.go b/util/commit.go index 942199f..c88e99c 100644 --- a/util/commit.go +++ b/util/commit.go @@ -1,7 +1,7 @@ package util import ( - git "gopkg.in/libgit2/git2go.v22" + git "gopkg.in/libgit2/git2go.v24" ) func CommitToTree(repo *git.Repository, hash string) (*git.Tree, error) { diff --git a/vendor/vendor.json b/vendor/vendor.json index 8b378c1..8dd0efb 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -36,9 +36,10 @@ "revision": "8808370bf63524e115da1371ba42bce6739f3a6b" }, { - "checksumSHA1": "wQudIit83haY5Ip3FD9Uxlz4QZA=", - "path": "gopkg.in/libgit2/git2go.v22", - "revision": "41ad00f868e7dfcdb04c7538f27350d400f710a3" + "checksumSHA1": "W9y5Ib20WD6Msz3iy7pfS4vRsb0=", + "path": "gopkg.in/libgit2/git2go.v24", + "revision": "8eaae73f85dd3df78df80d2dac066eb0866444ae", + "revisionTime": "2016-04-27T12:53:21Z" } ], "rootPath": "github.com/cpg1111/maestro"