Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
75 lines
1.3 KiB
Go
75 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package version
|
|
|
|
import (
|
|
"regexp"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
type V string
|
|
|
|
func (v V) GreaterThanOrEqualTo(other V) bool {
|
|
return !v.LessThan(other)
|
|
}
|
|
|
|
func (v V) LessThan(other V) bool {
|
|
leftParts, leftCount := split(v)
|
|
rightParts, rightCount := split(other)
|
|
|
|
length := max(leftCount, rightCount)
|
|
for i := range length {
|
|
var left, right string
|
|
|
|
if i < leftCount {
|
|
left = leftParts[i]
|
|
}
|
|
|
|
if i < rightCount {
|
|
right = rightParts[i]
|
|
}
|
|
|
|
if left == right {
|
|
continue
|
|
}
|
|
|
|
leftInt := parseInt(left)
|
|
rightInt := parseInt(right)
|
|
|
|
isNumericalComparison := leftInt != nil && rightInt != nil
|
|
|
|
if isNumericalComparison {
|
|
return *leftInt < *rightInt
|
|
}
|
|
|
|
return left < right
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func split(v V) ([]string, int) {
|
|
var chunks []string
|
|
|
|
for part := range strings.SplitSeq(string(v), ".") {
|
|
chunks = append(chunks, splitNumericalChunks(part)...)
|
|
}
|
|
|
|
return chunks, len(chunks)
|
|
}
|
|
|
|
var numericalOrAlphaRE = regexp.MustCompile(`(\d+|\D+)`)
|
|
|
|
func splitNumericalChunks(s string) []string {
|
|
return numericalOrAlphaRE.FindAllString(s, -1)
|
|
}
|
|
|
|
func parseInt(s string) *int64 {
|
|
if n, err := strconv.ParseInt(s, 10, 64); err == nil {
|
|
return &n
|
|
}
|
|
return nil
|
|
}
|