From 4f8f13fd76f065e49efdb3aa1a7504ffcafbf9a8 Mon Sep 17 00:00:00 2001 From: Jan-Philipp Benecke Date: Wed, 19 May 2021 00:49:33 +0200 Subject: Allow setting branch (#46) Support specifying the branch from which source will be served in the YAML configuration. --- config.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'config.go') diff --git a/config.go b/config.go index c40b2bd..1699e7f 100644 --- a/config.go +++ b/config.go @@ -10,6 +10,7 @@ import ( ) const _defaultGodocServer = "pkg.go.dev" +const _defaultBranch = "master" // Config represents the structure of the yaml file type Config struct { @@ -22,7 +23,8 @@ type Config struct { // Package details the options available for each repo type Package struct { - Repo string `yaml:"repo"` + Repo string `yaml:"repo"` + Branch string `yaml:"branch"` } // ensureAlphabetical checks that the packages are listed alphabetically in the configuration. @@ -75,5 +77,13 @@ func Parse(path string) (*Config, error) { c.Godoc.Host = host } + // set default branch + for v, p := range c.Packages { + if p.Branch == "" { + p.Branch = _defaultBranch + c.Packages[v] = p + } + } + return &c, err } -- cgit v1.2.3