mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00

Some checks are pending
Dendrite / WASM build test (push) Waiting to run
Dendrite / Linting (push) Waiting to run
Dendrite / Unit tests (push) Waiting to run
Dendrite / Build for Linux (push) Waiting to run
Dendrite / Build for Windows (push) Waiting to run
Dendrite / Initial tests passed (push) Blocked by required conditions
Dendrite / Integration tests (push) Blocked by required conditions
Dendrite / Upgrade tests (push) Blocked by required conditions
Dendrite / Upgrade tests from HEAD-2 (push) Blocked by required conditions
Dendrite / Sytest (SQLite Cgo) (push) Blocked by required conditions
Dendrite / Sytest (PostgreSQL) (push) Blocked by required conditions
Dendrite / Sytest (SQLite native) (push) Blocked by required conditions
Dendrite / Complement (PostgreSQL) (push) Blocked by required conditions
Dendrite / Complement (SQLite native) (push) Blocked by required conditions
Dendrite / Complement (SQLite Cgo) (push) Blocked by required conditions
Dendrite / Integration tests passed (push) Blocked by required conditions
Dendrite / Update Docker images (push) Blocked by required conditions
Also updates the README to: - highlight Dendrite is in maintenance mode - remove references to being "scalable" as we eventually decided to focus on smaller deployments not huge ones. - remove the progress section as it was horribly outdated and in general Dendrite is roughly feature complete with synapse (with the exception of sliding sync and OIDC, which is also now mentioned explicitly)
69 lines
1.4 KiB
Go
69 lines
1.4 KiB
Go
package internal
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime/debug"
|
|
"strings"
|
|
)
|
|
|
|
// the final version string
|
|
var version string
|
|
|
|
// -ldflags "-X github.com/element-hq/dendrite/internal.branch=master"
|
|
var branch string
|
|
|
|
// -ldflags "-X github.com/element-hq/dendrite/internal.build=alpha"
|
|
var build string
|
|
|
|
const (
|
|
VersionMajor = 0
|
|
VersionMinor = 15
|
|
VersionPatch = 0
|
|
VersionTag = "" // example: "rc1"
|
|
|
|
gitRevLen = 7 // 7 matches the displayed characters on github.com
|
|
)
|
|
|
|
func VersionString() string {
|
|
return version
|
|
}
|
|
|
|
func init() {
|
|
version = fmt.Sprintf("%d.%d.%d", VersionMajor, VersionMinor, VersionPatch)
|
|
if VersionTag != "" {
|
|
version += "-" + VersionTag
|
|
}
|
|
parts := []string{}
|
|
if build != "" {
|
|
parts = append(parts, build)
|
|
}
|
|
if branch != "" {
|
|
parts = append(parts, branch)
|
|
}
|
|
|
|
defer func() {
|
|
if len(parts) > 0 {
|
|
version += "+" + strings.Join(parts, ".")
|
|
}
|
|
}()
|
|
|
|
// Try to get the revision Dendrite was build from.
|
|
// If we can't, e.g. Dendrite wasn't built (go run) or no VCS version is present,
|
|
// we just use the provided version above.
|
|
info, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
for _, setting := range info.Settings {
|
|
if setting.Key == "vcs.revision" {
|
|
revLen := len(setting.Value)
|
|
if revLen >= gitRevLen {
|
|
parts = append(parts, setting.Value[:gitRevLen])
|
|
} else {
|
|
parts = append(parts, setting.Value[:revLen])
|
|
}
|
|
break
|
|
}
|
|
}
|
|
}
|