github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/plugin/checker/internal/version/comments.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package version
     5  
     6  import (
     7  	"regexp"
     8  	"strings"
     9  )
    10  
    11  var versionCommentRE = regexp.MustCompile(`^Minimum server version: (\d+\.\d+(?:\.\d+[\w-]*)?)$`)
    12  
    13  func ExtractMinimumVersionFromComment(s string) string {
    14  	lines := strings.Split(strings.TrimSpace(s), "\n")
    15  	if len(lines) > 0 {
    16  		lastLine := lines[len(lines)-1]
    17  		if m := versionCommentRE.FindStringSubmatch(lastLine); len(m) >= 1 {
    18  			return m[1]
    19  		}
    20  	}
    21  	return ""
    22  }