mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[REV] support clone code by tag,but do not pull.(#86)
This commit is contained in:
parent
cba307c7ae
commit
b8a222798a
@ -155,7 +155,11 @@ Loop:
|
|||||||
Depth: 1,
|
Depth: 1,
|
||||||
}
|
}
|
||||||
if csi.Branch != "" {
|
if csi.Branch != "" {
|
||||||
opts.ReferenceName = plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", csi.Branch))
|
if strings.HasPrefix(csi.Branch, "tag:") {
|
||||||
|
opts.ReferenceName = plumbing.ReferenceName(fmt.Sprintf("refs/tags/%s", csi.Branch[4:]))
|
||||||
|
} else {
|
||||||
|
opts.ReferenceName = plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", csi.Branch))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var rs *git.Repository
|
var rs *git.Repository
|
||||||
if ep.Protocol == "ssh" {
|
if ep.Protocol == "ssh" {
|
||||||
|
@ -46,6 +46,21 @@ func TestGitClone(t *testing.T) {
|
|||||||
commit, err := GetLastCommit(res)
|
commit, err := GetLastCommit(res)
|
||||||
t.Logf("%+v %+v", commit, err)
|
t.Logf("%+v %+v", commit, err)
|
||||||
}
|
}
|
||||||
|
func TestGitCloneByTag(t *testing.T) {
|
||||||
|
start := time.Now()
|
||||||
|
csi := CodeSourceInfo{
|
||||||
|
RepositoryURL: "https://github.com/goodrain/rainbond-install.git",
|
||||||
|
Branch: "tag:v3.5.1",
|
||||||
|
}
|
||||||
|
//logger := event.GetManager().GetLogger("system")
|
||||||
|
res, err := GitClone(csi, "/tmp/rainbonddoc4", nil, 1)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Logf("Take %d ms", time.Now().Unix()-start.Unix())
|
||||||
|
commit, err := GetLastCommit(res)
|
||||||
|
t.Logf("%+v %+v", commit, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestGitPull(t *testing.T) {
|
func TestGitPull(t *testing.T) {
|
||||||
csi := CodeSourceInfo{
|
csi := CodeSourceInfo{
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCreateRepostoryBuildInfo(t *testing.T) {
|
func TestCreateRepostoryBuildInfo(t *testing.T) {
|
||||||
info, err := CreateRepostoryBuildInfo("ssh://git@gr5042d6.7804f67d.ali-sh-s1.goodrain.net:20905/root/private2018.git?dir=abc", "master", "ADSASDADAD", "")
|
info, err := CreateRepostoryBuildInfo("ssh://git@gr5042d6.7804f67d.ali-sh-s1.goodrain.net:20905/root/private2018.git?dir=abc", "master", "ADSASDADAD", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user