diff options
author | 2023-05-09 11:29:37 -0700 | |
---|---|---|
committer | 2023-05-09 11:29:37 -0700 | |
commit | 2ef9d6a10e40c34a186cc6f1a081e9210169656b (patch) | |
tree | e504345a626ebc5bfc3e08854907d7382fd1cd19 | |
parent | eda20020c3391cf0a9aed04af1c349afbac66f90 (diff) | |
download | sally-2ef9d6a10e40c34a186cc6f1a081e9210169656b.tar.gz sally-2ef9d6a10e40c34a186cc6f1a081e9210169656b.tar.zst sally-2ef9d6a10e40c34a186cc6f1a081e9210169656b.zip |
Remove branch from PackageConfig struct (#93)
* Remove branch from PackageConfig struct
With #92, branch is no longer necessary from PackageConfig
struct since go-source tag was removed.
This removes Branch field from PackageConfig.
* update README
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | config.go | 17 | ||||
-rw-r--r-- | config_test.go | 23 | ||||
-rw-r--r-- | handler.go | 12 |
4 files changed, 6 insertions, 51 deletions
@@ -47,11 +47,6 @@ packages: # This field is required. repo: github.com/uber-go/zap - # Branch of the Git repository that you're linking to. - # - # Defaults to "master". - branch: master - # Optional description of the package. description: A fast, structured-logging library. @@ -9,7 +9,6 @@ import ( const ( _defaultGodocServer = "pkg.go.dev" - _defaultBranch = "master" ) // Config defines the configuration for a Sally server. @@ -42,14 +41,6 @@ type PackageConfig struct { // For example, "github.com/uber-go/sally". Repo string `yaml:"repo"` // required - // Branch is the default branch for the repository - // when no version is specified. - // - // Defaults to master. - Branch string `yaml:"branch"` - // NB: This is no longer necessary. - // https://github.com/uber-go/sally/issues/83 - // URL is the base URL of the vanity import for this module. // // Defaults to the URL specified in the top-level config. @@ -82,13 +73,5 @@ 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 } diff --git a/config_test.go b/config_test.go index 6587295..0eb93e2 100644 --- a/config_test.go +++ b/config_test.go @@ -29,26 +29,7 @@ packages: pkg, ok := config.Packages["grpc"] assert.True(t, ok) - assert.Equal(t, pkg, PackageConfig{Repo: "github.com/grpc/grpc-go", Branch: "main"}) -} - -func TestParseDefaultBranch(t *testing.T) { - path, clean := TempFile(t, ` - -url: google.golang.org -packages: - grpc: - repo: github.com/grpc/grpc-go - -`) - defer clean() - - config, err := Parse(path) - assert.NoError(t, err) - - pkg, ok := config.Packages["grpc"] - assert.True(t, ok) - assert.Equal(t, pkg, PackageConfig{Repo: "github.com/grpc/grpc-go", Branch: "master"}) + assert.Equal(t, pkg, PackageConfig{Repo: "github.com/grpc/grpc-go"}) } func TestParsePackageLevelURL(t *testing.T) { @@ -102,7 +83,7 @@ packages: pkg, ok := config.Packages["grpc"] assert.True(t, ok) - assert.Equal(t, PackageConfig{Repo: "github.com/grpc/grpc-go", Branch: "master"}, pkg) + assert.Equal(t, PackageConfig{Repo: "github.com/grpc/grpc-go"}, pkg) }) } } @@ -83,9 +83,6 @@ type packageHandler struct { // For example, "github.com/uber-go/zap". gitURL string - // Default branch of the Git repository. - defaultBranch string - // Canonical import path for the package. canonicalURL string } @@ -98,11 +95,10 @@ func newPackageHandler(cfg *Config, name string, pkg PackageConfig) *packageHand canonicalURL := fmt.Sprintf("%s/%s", baseURL, name) return &packageHandler{ - godocHost: cfg.Godoc.Host, - name: name, - canonicalURL: canonicalURL, - gitURL: pkg.Repo, - defaultBranch: pkg.Branch, + godocHost: cfg.Godoc.Host, + name: name, + canonicalURL: canonicalURL, + gitURL: pkg.Repo, } } |