From 668da42800b448aa1dd5dbcd009319aeff74abef Mon Sep 17 00:00:00 2001 From: timfeirg Date: Mon, 6 Feb 2017 17:53:32 +0800 Subject: [PATCH] use libgit2 0.25.1 --- .gitlab-ci.yml | 2 +- Makefile | 2 +- README.md | 9 --------- devtools/libgit2.rb.patch | 15 --------------- source/gitlab/cesium.go | 25 ++++++------------------- 5 files changed, 8 insertions(+), 45 deletions(-) delete mode 100644 devtools/libgit2.rb.patch diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5ecb7cb7..b97f412f0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: "hub.ricebook.net/base/centos:onbuild-eru-core-2016.12.16" +image: "hub.ricebook.net/base/centos:onbuild-eru-core-2017.02.06" before_script: - "ln -s $CI_PROJECT_DIR $GOPATH/src/gitlab.ricebook.net/platform/core" stages: diff --git a/Makefile b/Makefile index 3bfef6ba4..aba6141e6 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ deps: go get github.com/golang/protobuf/{proto,protoc-gen-go} || echo "oops" go get github.com/codegangsta/cli || echo "oops" go get gopkg.in/yaml.v2 || echo "oops" - go get gopkg.in/libgit2/git2go.v23 || echo "oops" + go get gopkg.in/libgit2/git2go.v25 || echo "oops" go get golang.org/x/net/context || echo "oops" go get google.golang.org/grpc || echo "oops" go get github.com/coreos/etcd || echo "oops" diff --git a/README.md b/README.md index 0cf78978d..787d2796e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,6 @@ Core ==== -## Install libgit2 -We use v0.23.4 because v0.24 sucks - -```shell -cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula -git checkout b0b94c4ee5ddec3a33d1ecb406f73b19642ec519 libgit2.rb -git commit -m 'override libgit2 version' -``` - ## DEV 生产服部署在 c2-eru-1,测试服部署在 c1-eru-1,如果需要测试,先更新 core,然后这样子部署: diff --git a/devtools/libgit2.rb.patch b/devtools/libgit2.rb.patch deleted file mode 100644 index b0bd1a261..000000000 --- a/devtools/libgit2.rb.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/Formula/libgit2.rb b/Formula/libgit2.rb -index b91f4ff..45205f1 100644 ---- a/Formula/libgit2.rb -+++ b/Formula/libgit2.rb -@@ -1,8 +1,8 @@ - class Libgit2 < Formula - desc "C library of Git core methods that is re-entrant and linkable" - homepage "https://libgit2.github.com/" -- url "https://github.com/libgit2/libgit2/archive/v0.24.2.tar.gz" -- sha256 "00f0a7403143fba69601accc80cacf49becc568b890ba232f300c1b2a37475e6" -+ url "https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz" -+ sha256 "c7f5e2d7381dbc4d7e878013d14f9993ae8a41bd23f032718e39ffba57894029" - head "https://github.com/libgit2/libgit2.git" - - bottle do diff --git a/source/gitlab/cesium.go b/source/gitlab/cesium.go index 7d0eb645f..ae21f6a77 100644 --- a/source/gitlab/cesium.go +++ b/source/gitlab/cesium.go @@ -13,7 +13,7 @@ import ( log "github.com/Sirupsen/logrus" "gitlab.ricebook.net/platform/core/types" - "gopkg.in/libgit2/git2go.v23" + "gopkg.in/libgit2/git2go.v25" ) type cesium struct { @@ -58,37 +58,24 @@ func (c *cesium) SourceCode(repository, path, revision string) error { repo, err := git.Clone(repository, path, cloneOpts) if err != nil { + log.Errorf("Error during Clone: %v", err.Error()) return err } if err := repo.CheckoutHead(nil); err != nil { + log.Errorf("Error during CheckoutHead: %v", err.Error()) return err } object, err := repo.RevparseSingle(revision) if err != nil { + log.Errorf("Error during RevparseSingle: %v", err.Error()) return err } defer object.Free() + commit, err := object.AsCommit() - // below is code for v24 - // which is fucking unstable - // ------------------------- - // - // tree, err := object.AsTree() - // if err != nil { - // return err - // } - obj, err := object.Peel(git.ObjectTree) - if err != nil { - return err - } - - tree, ok := obj.(*git.Tree) - if !ok { - return fmt.Errorf("git object is not a tree") - } - return repo.CheckoutTree(tree, &git.CheckoutOpts{Strategy: git.CheckoutSafe}) + return repo.ResetToCommit(commit, git.ResetHard, &git.CheckoutOpts{Strategy: git.CheckoutSafe}) } // Download artifact to path, and unzip it