added supported git tags
This commit is contained in:
parent
99baaea4f7
commit
8051c9f945
@ -34,6 +34,10 @@ inputs:
|
||||
description: 'Supported lfs module or not'
|
||||
required: false
|
||||
default: false
|
||||
fetchtags:
|
||||
description: 'power download tag or not'
|
||||
required: false
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: 'go'
|
||||
|
@ -18,6 +18,7 @@ type Config struct {
|
||||
FetchDepth string
|
||||
Clean bool
|
||||
LFS bool
|
||||
FetchTags bool
|
||||
}
|
||||
|
||||
// todo filter, sparse-checkout, sparse-checkout-cone-mode, fetch-tags, show-progress, submodules, set-safe-directory
|
||||
@ -48,6 +49,12 @@ func getConfig() Config {
|
||||
lfsBool = true
|
||||
}
|
||||
|
||||
fetchTags := os.Getenv("INPUT_FETCHTAGS")
|
||||
fetchTagsBool := false
|
||||
if fetchTags == "1" || fetchTags == "true" || fetchTags == "t" {
|
||||
fetchTagsBool = true
|
||||
}
|
||||
|
||||
return Config{
|
||||
Repository: os.Getenv("INPUT_REPOSITORY"),
|
||||
Ref: os.Getenv("INPUT_REF"),
|
||||
@ -58,6 +65,7 @@ func getConfig() Config {
|
||||
FetchDepth: fetchDepth,
|
||||
Clean: cleanBool,
|
||||
LFS: lfsBool,
|
||||
FetchTags: fetchTagsBool,
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,11 +97,23 @@ func main() {
|
||||
cloneURL := cfg.CheckoutType.GenerateCloneURL(cfg)
|
||||
|
||||
fmt.Println("Cloning", cloneURL, "into", cfg.Path)
|
||||
run("git", "clone", fmt.Sprintf("--depth=%s", cfg.FetchDepth), cloneURL, cfg.Path)
|
||||
|
||||
cloneArgs := []string{"clone"}
|
||||
if cfg.FetchTags {
|
||||
cloneArgs = append(cloneArgs, "--tags")
|
||||
}
|
||||
cloneArgs = append(cloneArgs, fmt.Sprintf("--depth=%s", cfg.FetchDepth), cloneURL, cfg.Path)
|
||||
run("git", cloneArgs...)
|
||||
|
||||
if cfg.Ref != "" {
|
||||
fmt.Println("Checking out", cfg.Ref)
|
||||
run("git", "-C", cfg.Path, "fetch", fmt.Sprintf("--depth=%s", cfg.FetchDepth), "origin", cfg.Ref)
|
||||
|
||||
fetchArgs := []string{"-C", cfg.Path, "fetch"}
|
||||
if cfg.FetchTags {
|
||||
fetchArgs = append(fetchArgs, "--tags")
|
||||
}
|
||||
fetchArgs = append(fetchArgs, fmt.Sprintf("--depth=%s", cfg.FetchDepth), "origin", cfg.Ref)
|
||||
run("git", fetchArgs...)
|
||||
run("git", "-C", cfg.Path, "checkout", "FETCH_HEAD")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user