forked from woodpecker-ci/plugin-git
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaults.go
More file actions
35 lines (28 loc) · 743 Bytes
/
defaults.go
File metadata and controls
35 lines (28 loc) · 743 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fmt"
"github.com/adrg/xdg"
"github.com/urfave/cli/v2"
)
func SetDefaults(c *cli.Context, p *Plugin) {
if p.Pipeline.Event == "tag" && !c.IsSet("tags") {
// tags clone not explicit set but pipeline is triggered by a tag
// auto set tags cloning to true
p.Config.Tags = true
}
if c.IsSet("tags") && c.IsSet("partial") {
fmt.Println("WARNING: ignore partial clone as tags are fetched")
}
if p.Config.Tags && p.Config.Partial {
// if tag fetching is enabled per event or setting, disable partial clone
p.Config.Partial = false
}
if p.Config.Partial {
p.Config.Depth = 1
p.Config.filter = "tree:0"
}
if len(p.Config.Home) == 0 {
// fallback to system home
p.Config.Home = xdg.Home
}
}