mirror of
https://github.com/thegeeklab/wp-git-clone.git
synced 2024-11-22 00:10:39 +00:00
fix: use special step to retrieve tags and suppress output
This commit is contained in:
parent
d93763eccd
commit
b83b48bed6
29
git/clone.go
29
git/clone.go
@ -7,16 +7,9 @@ import (
|
||||
)
|
||||
|
||||
// FetchSource fetches the source from remote.
|
||||
func FetchSource(ref string, tags bool, depth int, filter string) *execabs.Cmd {
|
||||
tagsOption := "--tags"
|
||||
|
||||
if !tags {
|
||||
tagsOption = "--no-tags"
|
||||
}
|
||||
|
||||
func FetchSource(ref string, depth int, filter string) *execabs.Cmd {
|
||||
args := []string{
|
||||
"fetch",
|
||||
tagsOption,
|
||||
}
|
||||
|
||||
if depth != 0 {
|
||||
@ -36,6 +29,21 @@ func FetchSource(ref string, tags bool, depth int, filter string) *execabs.Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
// FetchTags fetches the source from remote.
|
||||
func FetchTags() *execabs.Cmd {
|
||||
args := []string{
|
||||
"fetch",
|
||||
"--tags",
|
||||
"--quiet",
|
||||
"origin",
|
||||
}
|
||||
|
||||
return execabs.Command(
|
||||
gitBin,
|
||||
args...,
|
||||
)
|
||||
}
|
||||
|
||||
// FetchLFS fetches lfs.
|
||||
func FetchLFS() *execabs.Cmd {
|
||||
args := []string{
|
||||
@ -53,7 +61,8 @@ func FetchLFS() *execabs.Cmd {
|
||||
func CheckoutHead() *execabs.Cmd {
|
||||
args := []string{
|
||||
"checkout",
|
||||
"-qf",
|
||||
"--force",
|
||||
"--quiet",
|
||||
"FETCH_HEAD",
|
||||
}
|
||||
|
||||
@ -68,7 +77,7 @@ func CheckoutSha(repo Repository) *execabs.Cmd {
|
||||
args := []string{
|
||||
"reset",
|
||||
"--hard",
|
||||
"-q",
|
||||
"--quiet",
|
||||
repo.CommitSha,
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ func TestFetch(t *testing.T) {
|
||||
[]string{
|
||||
"/usr/bin/git",
|
||||
"fetch",
|
||||
"--no-tags",
|
||||
"origin",
|
||||
"+refs/heads/master:",
|
||||
},
|
||||
@ -31,7 +30,6 @@ func TestFetch(t *testing.T) {
|
||||
[]string{
|
||||
"/usr/bin/git",
|
||||
"fetch",
|
||||
"--no-tags",
|
||||
"--depth=50",
|
||||
"origin",
|
||||
"+refs/heads/master:",
|
||||
@ -44,7 +42,6 @@ func TestFetch(t *testing.T) {
|
||||
[]string{
|
||||
"/usr/bin/git",
|
||||
"fetch",
|
||||
"--tags",
|
||||
"--depth=100",
|
||||
"origin",
|
||||
"+refs/heads/master:",
|
||||
@ -52,7 +49,7 @@ func TestFetch(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, td := range testdata {
|
||||
c := FetchSource(td.ref, td.tags, td.depth, "")
|
||||
c := FetchSource(td.ref, td.depth, "")
|
||||
if len(c.Args) != len(td.exp) {
|
||||
t.Errorf("Expected: %s, got %s", td.exp, c.Args)
|
||||
}
|
||||
|
@ -110,13 +110,17 @@ func (p *Plugin) Execute() error {
|
||||
// fetch and checkout by ref
|
||||
log.Info().Msg("no commit information: using head checkout")
|
||||
|
||||
cmds = append(cmds, git.FetchSource(p.Settings.Repo.CommitRef, p.Settings.Tags, p.Settings.Depth, p.Settings.Filter))
|
||||
cmds = append(cmds, git.FetchSource(p.Settings.Repo.CommitRef, p.Settings.Depth, p.Settings.Filter))
|
||||
cmds = append(cmds, git.CheckoutHead())
|
||||
} else {
|
||||
cmds = append(cmds, git.FetchSource(p.Settings.Repo.CommitSha, p.Settings.Tags, p.Settings.Depth, p.Settings.Filter))
|
||||
cmds = append(cmds, git.FetchSource(p.Settings.Repo.CommitSha, p.Settings.Depth, p.Settings.Filter))
|
||||
cmds = append(cmds, git.CheckoutSha(p.Settings.Repo))
|
||||
}
|
||||
|
||||
if p.Settings.Tags {
|
||||
cmds = append(cmds, git.FetchTags())
|
||||
}
|
||||
|
||||
for name, submoduleURL := range p.Settings.Repo.Submodules {
|
||||
cmds = append(cmds, git.ConfigRemapSubmodule(name, submoduleURL))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user