From 7c7e42e7aef3c3e31c8c1063a00595c4f4a722b1 Mon Sep 17 00:00:00 2001 From: Ascendise Date: Sat, 26 Oct 2024 14:44:58 +0200 Subject: [PATCH] add option to set defaultRef --- pkg/gitea/gitea.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/gitea/gitea.go b/pkg/gitea/gitea.go index ef496e8..ea74904 100644 --- a/pkg/gitea/gitea.go +++ b/pkg/gitea/gitea.go @@ -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") +}