all repos — website @ b27825139e77cd8c527ada7c712f186c94444c04

My website

brand exe with both long and short commit hashes

Alan Pearce
commit

b27825139e77cd8c527ada7c712f186c94444c04

parent

ac9646a38aaa39ca9cb7e0aa2efa370e463abaa0

3 files changed, 16 insertions(+), 5 deletions(-)

changed files
M cmd/server/main.gocmd/server/main.go
@@ -11,6 +11,11 @@ "github.com/ardanlabs/conf/v3"
"github.com/pkg/errors" ) +var ( + CommitSHA string + ShortSHA string +) + type Config struct { Production bool `conf:"default:false"` ListenAddress string `conf:"default:localhost"`
M cmd/server/server.gocmd/server/server.go
@@ -19,8 +19,6 @@ sentryhttp "github.com/getsentry/sentry-go/http"
"github.com/shengyanli1982/law" ) -var Commit string - var config *cfg.Config type HTTPError struct {
@@ -71,7 +69,7 @@ w.WriteHeader(http.StatusInternalServerError)
slog.Error("runtime panic!", "error", fail) } }() - w.Header().Set("Server", fmt.Sprintf("website (%s)", Commit)) + w.Header().Set("Server", fmt.Sprintf("website (%s)", ShortSHA)) if err := fn(w, r); err != nil { if strings.Contains(r.Header.Get("Accept"), "text/html") { w.WriteHeader(err.Code)
@@ -119,7 +117,7 @@ err = sentry.Init(sentry.ClientOptions{
EnableTracing: true, TracesSampleRate: 1.0, Dsn: os.Getenv("SENTRY_DSN"), - Release: Commit, + Release: CommitSHA, Environment: env, }) if err != nil {
M nix/default.nixnix/default.nix
@@ -1,6 +1,7 @@
{ pkgs, self }: let version = "unstable"; + shortSHA = self.shortRev or self.dirtyShortRev; fullSHA = self.rev or self.dirtyRev; mkDocker = type: { server, website }: let
@@ -75,7 +76,14 @@ ];
}; modules = ./gomod2nix.toml; subPackages = [ "cmd/server" ]; - ldflags = [ "-s" "-w" "-X" "main.Commit=${fullSHA}" ]; + ldflags = [ + "-s" + "-w" + "-X" + "main.CommitSHA=${fullSHA}" + "-X" + "main.ShortSHA=${shortSHA}" + ]; }; docker-stream = mkDockerStream { inherit server website; }; docker-stream-aarch64-linux = mkDockerStream {