mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Patchset for 21
Added Version -u to update the checked out libaraies Enhanced new skeleton toto support http https and git schemas when cloning the skeleton repo. Enhanced version command to fetch server version from master branch Enhanced version command to update local repository if a new version exists on the server
This commit is contained in:
@@ -13,6 +13,8 @@ type Version struct {
|
||||
Minor int
|
||||
Maintenance int
|
||||
Suffix string
|
||||
BuildDate string
|
||||
MinGoVersion string
|
||||
}
|
||||
|
||||
// The compatibility list
|
||||
@@ -27,6 +29,13 @@ var versionRegExp = regexp.MustCompile(`([^\d]*)?([0-9]*)\.([0-9]*)(\.([0-9]*))?
|
||||
// Parse the version and return it as a Version object
|
||||
func ParseVersion(version string) (v *Version, err error) {
|
||||
|
||||
v = &Version{}
|
||||
return v, v.ParseVersion(version)
|
||||
}
|
||||
|
||||
// Parse the version and return it as a Version object
|
||||
func (v *Version)ParseVersion(version string) (err error) {
|
||||
|
||||
parsedResult := versionRegExp.FindAllStringSubmatch(version, -1)
|
||||
if len(parsedResult) != 1 {
|
||||
err = errors.Errorf("Invalid version %s", version)
|
||||
@@ -36,7 +45,7 @@ func ParseVersion(version string) (v *Version, err error) {
|
||||
err = errors.Errorf("Invalid version %s", version)
|
||||
return
|
||||
}
|
||||
v = &Version{}
|
||||
|
||||
v.Prefix = parsedResult[0][1]
|
||||
v.Major = v.intOrZero(parsedResult[0][2])
|
||||
v.Minor = v.intOrZero(parsedResult[0][3])
|
||||
@@ -45,7 +54,6 @@ func ParseVersion(version string) (v *Version, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Returns 0 or an int value for the string, errors are returned as 0
|
||||
func (v *Version) intOrZero(input string) (value int) {
|
||||
if input != "" {
|
||||
@@ -105,6 +113,12 @@ func (v *Version) Newer(o *Version) bool {
|
||||
}
|
||||
|
||||
// Convert the version to a string
|
||||
func (v *Version) String() string {
|
||||
func (v *Version) VersionString() string {
|
||||
return fmt.Sprintf("%s%d.%d.%d%s", v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix)
|
||||
}
|
||||
|
||||
// Convert the version build date and go version to a string
|
||||
func (v *Version) String() string {
|
||||
return fmt.Sprintf("Version: %s%d.%d.%d%s\nBuild Date: %s\n Minimium Go Version: %s",
|
||||
v.Prefix, v.Major, v.Minor, v.Maintenance, v.Suffix, v.BuildDate, v.MinGoVersion)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user