add option to set defaultRef

This commit is contained in:
Ascendise 2024-10-26 14:44:58 +02:00
parent 48923386b3
commit 7c7e42e7ae
No known key found for this signature in database

View file

@ -94,6 +94,11 @@ func (c *Client) Open(name, ref string) (fs.File, error) {
hasConfig = false 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 // if we don't have a config and the repo is the gitea-pages
// always overwrite the ref to the gitea-pages branch // always overwrite the ref to the gitea-pages branch
if !hasConfig && (repo == c.giteapages || ref == c.giteapages) { if !hasConfig && (repo == c.giteapages || ref == c.giteapages) {
@ -270,3 +275,10 @@ func validRefs(ref string, allowall bool) bool {
return false return false
} }
func getDefaultPagesRef() string {
if !viper.IsSet("defaultRef") {
return ""
}
return viper.GetString("defaultRef")
}