mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
updated CommitDate to fallback into default time
This commit is contained in:
committed by
Dan Christian Bogos
parent
109739d64d
commit
05e6e2660c
@@ -761,10 +761,12 @@ func GetCGRVersion() (vers string, err error) {
|
|||||||
var commitHash string
|
var commitHash string
|
||||||
var commitDate time.Time
|
var commitDate time.Time
|
||||||
var matched bool
|
var matched bool
|
||||||
commitDate, err = time.Parse("2006-01-02T15:04:05-07:00", strings.TrimSpace(GitCommitDate))
|
|
||||||
if err != nil {
|
commitDate, _ = time.Parse("2006-01-02T15:04:05-07:00", strings.TrimSpace(GitCommitDate))
|
||||||
return vers, fmt.Errorf("Building version - error: <%s> compiling commit date", err.Error())
|
//ignoring err temporarily until a future fix since we dont get correct date format in older linux distributions
|
||||||
}
|
//if err != nil {
|
||||||
|
//return vers, fmt.Errorf("Building version - error: <%s> compiling commit date", err.Error())
|
||||||
|
//}
|
||||||
matched, err = regexp.MatchString("^[0-9a-f]{12,}$", GitCommitHash)
|
matched, err = regexp.MatchString("^[0-9a-f]{12,}$", GitCommitHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return vers, fmt.Errorf("Building version - error: <%s> compiling commit hash", err.Error())
|
return vers, fmt.Errorf("Building version - error: <%s> compiling commit hash", err.Error())
|
||||||
|
|||||||
@@ -1319,13 +1319,13 @@ func TestGetCGRVersion(t *testing.T) {
|
|||||||
} else if vers != expVers {
|
} else if vers != expVers {
|
||||||
t.Errorf("Expecting: <%s>, received: <%s>", expVers, vers)
|
t.Errorf("Expecting: <%s>, received: <%s>", expVers, vers)
|
||||||
}
|
}
|
||||||
GitCommitDate = "wrong format"
|
// GitCommitDate = "wrong format"
|
||||||
GitCommitHash = "73014daa0c1d7edcb532d5fe600b8a20d588cdf8"
|
// GitCommitHash = "73014daa0c1d7edcb532d5fe600b8a20d588cdf8"
|
||||||
if vers, err := GetCGRVersion(); err == nil || err.Error() != `Building version - error: <parsing time "wrong format" as "2006-01-02T15:04:05-07:00": cannot parse "wrong format" as "2006"> compiling commit date` {
|
// if vers, err := GetCGRVersion(); err == nil || err.Error() != `Building version - error: <parsing time "wrong format" as "2006-01-02T15:04:05-07:00": cannot parse "wrong format" as "2006"> compiling commit date` {
|
||||||
t.Error(err)
|
// t.Error(err)
|
||||||
} else if vers != expVers {
|
// } else if vers != expVers {
|
||||||
t.Errorf("Expecting: <%s>, received: <%s>", expVers, vers)
|
// t.Errorf("Expecting: <%s>, received: <%s>", expVers, vers)
|
||||||
}
|
// }
|
||||||
GitCommitDate = "2016-12-30T19:48:09+01:00"
|
GitCommitDate = "2016-12-30T19:48:09+01:00"
|
||||||
GitCommitHash = "73014DAA0C1D7EDCB532D5FE600B8A20D588CDF8"
|
GitCommitHash = "73014DAA0C1D7EDCB532D5FE600B8A20D588CDF8"
|
||||||
if vers, err := GetCGRVersion(); err == nil || err.Error() != `Building version - error: <Regex not matched> compiling commit hash` {
|
if vers, err := GetCGRVersion(); err == nil || err.Error() != `Building version - error: <Regex not matched> compiling commit hash` {
|
||||||
|
|||||||
Reference in New Issue
Block a user