diff options
-rw-r--r-- | cmd/searchix-web/main.go | 8 | ||||
-rw-r--r-- | internal/config/config.go | 5 | ||||
-rw-r--r-- | internal/fetcher/http.go | 2 | ||||
-rw-r--r-- | internal/server/error.go | 1 | ||||
-rw-r--r-- | internal/server/headers.go | 2 | ||||
-rw-r--r-- | internal/server/mux.go | 14 | ||||
-rw-r--r-- | nix/package.nix | 10 | ||||
-rw-r--r-- | nix/pre-commit-checks.nix | 2 |
8 files changed, 6 insertions, 38 deletions
diff --git a/cmd/searchix-web/main.go b/cmd/searchix-web/main.go index 91ecc7a..f065a84 100644 --- a/cmd/searchix-web/main.go +++ b/cmd/searchix-web/main.go @@ -13,8 +13,6 @@ import ( "searchix/internal/config" ) -var buildVersion string - var ( configFile = flag.String("config", "config.toml", "config `file` to use") printDefaultConfig = flag.Bool( @@ -31,11 +29,7 @@ var ( func main() { flag.Parse() if *version { - fmt.Fprintf(os.Stderr, "searchix %s", buildVersion) - if buildVersion != config.CommitSHA && buildVersion != config.ShortSHA { - fmt.Fprintf(os.Stderr, " %s", config.CommitSHA) - } - _, err := fmt.Fprint(os.Stderr, "\n") + _, err := fmt.Fprintf(os.Stderr, "searchix %s\n", config.Version) if err != nil { panic("can't write to standard error?!") } diff --git a/internal/config/config.go b/internal/config/config.go index c2e026c..1ba5825 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,10 +11,7 @@ import ( "github.com/pkg/errors" ) -var ( - CommitSHA string - ShortSHA string -) +var Version string type URL struct { *url.URL diff --git a/internal/fetcher/http.go b/internal/fetcher/http.go index 675c3b3..1a47f11 100644 --- a/internal/fetcher/http.go +++ b/internal/fetcher/http.go @@ -47,7 +47,7 @@ func fetchFileIfNeeded( return } - req.Header.Set("User-Agent", fmt.Sprintf("Searchix %s", config.ShortSHA)) + req.Header.Set("User-Agent", fmt.Sprintf("Searchix %s", config.Version)) if ifModifiedSince != "" { req.Header.Set("If-Modified-Since", ifModifiedSince) diff --git a/internal/server/error.go b/internal/server/error.go index 6994ad7..e700d3b 100644 --- a/internal/server/error.go +++ b/internal/server/error.go @@ -17,7 +17,6 @@ func createErrorHandler( indexData := TemplateData{ ExtraHeadHTML: config.Web.ExtraHeadHTML, Sources: config.Importer.Sources, - Version: *versionInfo, Code: code, Message: message, } diff --git a/internal/server/headers.go b/internal/server/headers.go index 562fccc..7ff9fb9 100644 --- a/internal/server/headers.go +++ b/internal/server/headers.go @@ -11,7 +11,7 @@ func AddHeadersMiddleware(next http.Handler, config *cfg.Config) http.Handler { w.Header().Add(h, v) } w.Header().Add("Content-Security-Policy", config.Web.ContentSecurityPolicy.String()) - w.Header().Add("Server", "searchix/"+cfg.ShortSHA) + w.Header().Add("Server", "searchix/"+cfg.Version) next.ServeHTTP(w, r) }) diff --git a/internal/server/mux.go b/internal/server/mux.go index c2469ad..ea4b70c 100644 --- a/internal/server/mux.go +++ b/internal/server/mux.go @@ -34,11 +34,6 @@ type HTTPError struct { const jsSnippet = template.HTML(livereload.JsSnippet) // #nosec G203 -type VersionInfo struct { - ShortSHA string - CommitSHA string -} - type TemplateData struct { Sources map[string]*config.Source Source config.Source @@ -46,7 +41,6 @@ type TemplateData struct { Results bool SourceResult *bleve.SearchResult ExtraHeadHTML template.HTML - Version VersionInfo Code int Message string } @@ -60,11 +54,6 @@ type ResultData struct { Next string } -var versionInfo = &VersionInfo{ - ShortSHA: config.ShortSHA, - CommitSHA: config.CommitSHA, -} - var templates TemplateCollection func applyDevModeOverrides(cfg *config.Config) { @@ -105,7 +94,6 @@ func NewMux( indexData := TemplateData{ ExtraHeadHTML: cfg.Web.ExtraHeadHTML, Sources: cfg.Importer.Sources, - Version: *versionInfo, } w.Header().Add("Cache-Control", "max-age=86400") err := templates["index"].Execute(w, indexData) @@ -154,7 +142,6 @@ func NewMux( ExtraHeadHTML: cfg.Web.ExtraHeadHTML, Source: *source, Sources: cfg.Importer.Sources, - Version: *versionInfo, }, ResultsPerPage: search.ResultsPerPage, Query: qs, @@ -218,7 +205,6 @@ func NewMux( Sources: cfg.Importer.Sources, Source: *source, SourceResult: sourceResult, - Version: *versionInfo, }) if err != nil { errorHandler(w, r, err.Error(), http.StatusInternalServerError) diff --git a/nix/package.nix b/nix/package.nix index 99eeb88..c45599a 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -11,12 +11,8 @@ ) , buildGoApplication ? pkgs.buildGoApplication , css -, self -, testers }: let - inherit (builtins) concatStringsSep match; - version = "0.1.4"; in buildGoApplication { @@ -47,11 +43,7 @@ buildGoApplication { "-s" "-w" "-X" - "searchix/internal/config.CommitSHA=${self.rev or self.dirtyRev or "unknown"}" - "-X" - "searchix/internal/config.ShortSHA=${self.shortRev or self.dirtyShortRev or "unknown"}" - "-X" - "main.buildVersion=${version}" + "searchix/internal/config.Version=${version}" ]; modules = ../gomod2nix.toml; diff --git a/nix/pre-commit-checks.nix b/nix/pre-commit-checks.nix index 5f62494..c3c0f23 100644 --- a/nix/pre-commit-checks.nix +++ b/nix/pre-commit-checks.nix @@ -107,7 +107,7 @@ rec { entry = let script = pkgs.writeShellScript "generate-default-config" '' - ${pkgs.wgo}/bin/wgo run -exit searchix.go --print-default-config > defaults.toml + ${pkgs.wgo}/bin/wgo run -exit ./cmd/searchix-web --print-default-config > defaults.toml ''; in builtins.toString script; |