Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa2cfbf

Browse files
authored
Merge pull request #76 from arduino/per1234/version-timestamp
Add build timestamp to the --version output
2 parents 385b1e8 + c2aaa06 commit aa2cfbf

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

‎Taskfile.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,10 @@ vars:
184184
# build vars
185185
COMMIT:
186186
sh: echo "$(git log -n 1 --format=%h)"
187+
TIMESTAMP:
188+
sh: echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
187189
LDFLAGS: >
188-
-ldflags '-X github.com/arduino/arduino-check/configuration.commit={{.COMMIT}}'
190+
-ldflags '-X github.com/arduino/arduino-check/configuration.commit={{.COMMIT}} -X github.com/arduino/arduino-check/configuration.buildTimestamp={{.TIMESTAMP}}'
189191
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
190192

191193
GOLINTFLAGS: "-min_confidence 0.8 -set_exit_status"

‎cli/cli.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func Root() *cobra.Command {
3939
rootCommand.PersistentFlags().String("project-type", "all", "Only check projects of the specified type and their subprojects. Can be {sketch|library|all}.")
4040
rootCommand.PersistentFlags().Bool("recursive", true, "Search path recursively for Arduino projects to check. Can be {true|false}.")
4141
rootCommand.PersistentFlags().String("report-file", "", "Save a report on the checks to this file.")
42-
rootCommand.PersistentFlags().Bool("version", false, "Print version.")
42+
rootCommand.PersistentFlags().Bool("version", false, "Print version and timestamp of the build.")
4343

4444
return rootCommand
4545
}

‎command/command.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ func ArduinoCheck(rootCommand *cobra.Command, cliArguments []string) {
3939

4040
if configuration.VersionMode() {
4141
if configuration.OutputFormat() == outputformat.Text {
42-
fmt.Println(configuration.Version())
42+
fmt.Println(configuration.Version()+" "+configuration.BuildTimestamp())
4343
} else {
4444
versionObject := struct {
45-
Version string `json:"version"`
45+
Version string `json:"version"`
46+
BuildTimestamp string `json:"buildTimestamp"`
4647
}{
47-
Version: configuration.Version(),
48+
Version: configuration.Version(),
49+
BuildTimestamp: configuration.BuildTimestamp(),
4850
}
4951
versionJSON, err := json.MarshalIndent(versionObject, "", " ")
5052
if err != nil {

‎configuration/configuration.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ func Version() string {
193193
return version
194194
}
195195

196+
var buildTimestamp string
197+
198+
func BuildTimestamp() string {
199+
return buildTimestamp
200+
}
201+
196202
var targetPaths paths.PathList
197203

198204
// TargetPaths returns the projects search paths.

‎configuration/configuration_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,8 @@ func TestVersion(t *testing.T) {
220220
version = "42.1.2"
221221
assert.Equal(t, version, Version())
222222
}
223+
224+
func TestBuildTimestamp(t *testing.T) {
225+
buildTimestamp = "2020年11月27日T04:05:19+00:00"
226+
assert.Equal(t, buildTimestamp, BuildTimestamp())
227+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /