aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sung Yoon Whang <sungyoon@uber.com> 2023-05-09 11:29:37 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-09 11:29:37 -0700
commit2ef9d6a10e40c34a186cc6f1a081e9210169656b (patch)
treee504345a626ebc5bfc3e08854907d7382fd1cd19
parenteda20020c3391cf0a9aed04af1c349afbac66f90 (diff)
downloadsally-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.md5
-rw-r--r--config.go17
-rw-r--r--config_test.go23
-rw-r--r--handler.go12
4 files changed, 6 insertions, 51 deletions
diff --git a/README.md b/README.md
index 125cd19..77fcadf 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/config.go b/config.go
index 4d60a36..439bc48 100644
--- a/config.go
+++ b/config.go
@@ -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)
})
}
}
diff --git a/handler.go b/handler.go
index aa646c6..18dd1f4 100644
--- a/handler.go
+++ b/handler.go
@@ -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,
}
}