add option to set defaultRef
This commit is contained in:
parent
48923386b3
commit
7c7e42e7ae
1 changed files with 12 additions and 0 deletions
|
@ -94,6 +94,11 @@ func (c *Client) Open(name, ref string) (fs.File, error) {
|
|||
hasConfig = false
|
||||
}
|
||||
|
||||
// Overwrite default ref if specified
|
||||
if ref == "" && repo != c.giteapages && hasConfig {
|
||||
ref = getDefaultPagesRef()
|
||||
}
|
||||
|
||||
// if we don't have a config and the repo is the gitea-pages
|
||||
// always overwrite the ref to the gitea-pages branch
|
||||
if !hasConfig && (repo == c.giteapages || ref == c.giteapages) {
|
||||
|
@ -270,3 +275,10 @@ func validRefs(ref string, allowall bool) bool {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
func getDefaultPagesRef() string {
|
||||
if !viper.IsSet("defaultRef") {
|
||||
return ""
|
||||
}
|
||||
return viper.GetString("defaultRef")
|
||||
}
|
||||
|
|
Reference in a new issue