Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
d876ac92
Commit
d876ac92
authored
Jul 19, 2019
by
Y.Horie
Committed by
Massimiliano Pippi
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix time format RFC3339 in version #283 (#287)
parent
e249fbf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
9 deletions
+21
-9
version/version.go
version/version.go
+19
-7
version/version_test.go
version/version_test.go
+2
-2
No files found.
version/version.go
View file @
d876ac92
...
...
@@ -26,15 +26,27 @@ var (
defaultVersionString
=
"0.3.7-alpha.preview"
versionString
=
""
commit
=
""
buildDate
=
time
.
Time
{}
buildDate
=
rfc3339
Time
{}
)
type
rfc3339Time
struct
{
time
.
Time
}
func
(
r
rfc3339Time
)
format
()
string
{
return
r
.
Time
.
Format
(
time
.
RFC3339
)
}
func
(
r
rfc3339Time
)
MarshalJSON
()
([]
byte
,
error
)
{
return
[]
byte
(
`"`
+
r
.
format
()
+
`"`
),
nil
}
// Info FIXMEDOC
type
Info
struct
{
Application
string
`json:"Application"`
VersionString
string
`json:"VersionString"`
Commit
string
`json:"Commit"`
BuildDate
time
.
Time
`json:"BuildDate"`
Application
string
`json:"Application"`
VersionString
string
`json:"VersionString"`
Commit
string
`json:"Commit"`
BuildDate
rfc3339
Time
`json:"BuildDate"`
}
// NewInfo FIXMEDOC
...
...
@@ -48,7 +60,7 @@ func NewInfo(application string) *Info {
}
func
(
i
*
Info
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s Version: %s Commit: %s BuildDate: %s"
,
i
.
Application
,
i
.
VersionString
,
i
.
Commit
,
i
.
BuildDate
)
return
fmt
.
Sprintf
(
"%s Version: %s Commit: %s BuildDate: %s"
,
i
.
Application
,
i
.
VersionString
,
i
.
Commit
,
i
.
BuildDate
.
format
()
)
}
//nolint:gochecknoinits
...
...
@@ -56,5 +68,5 @@ func init() {
if
versionString
==
""
{
versionString
=
defaultVersionString
}
buildDate
=
time
.
Now
()
.
UTC
()
buildDate
=
rfc3339Time
{
time
.
Now
()
.
UTC
()}
}
version/version_test.go
View file @
d876ac92
...
...
@@ -38,12 +38,12 @@ func TestIntegrationBuildInjectedInfo(t *testing.T) {
Application
:
goldenAppName
,
VersionString
:
"0.0.0-test.preview"
,
Commit
:
"deadbeef"
,
BuildDate
:
time
.
Time
{
},
BuildDate
:
rfc3339Time
{
time
.
Time
{}
},
}
info
:=
NewInfo
(
goldenAppName
)
require
.
Equal
(
t
,
goldenInfo
.
Application
,
info
.
Application
)
require
.
Equal
(
t
,
goldenInfo
.
VersionString
,
info
.
VersionString
)
require
.
Equal
(
t
,
goldenInfo
.
Commit
,
info
.
Commit
)
require
.
IsType
(
t
,
time
.
Time
{
},
info
.
BuildDate
)
require
.
IsType
(
t
,
rfc3339Time
{
time
.
Time
{}
},
info
.
BuildDate
)
require
.
False
(
t
,
info
.
BuildDate
.
IsZero
())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment