Skip to content

Commit

Permalink
Merge branch 'refactor/libgit2' into 'master'
Browse files Browse the repository at this point in the history
use libgit2 0.25.1

See merge request !54
  • Loading branch information
timfeirg committed Feb 7, 2017
2 parents 81816e9 + 668da42 commit 8ac261f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .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:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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"
Expand Down
9 changes: 0 additions & 9 deletions 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,然后这样子部署:
Expand Down
15 changes: 0 additions & 15 deletions devtools/libgit2.rb.patch

This file was deleted.

25 changes: 6 additions & 19 deletions source/gitlab/cesium.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8ac261f

Please sign in to comment.