Skip to content

Commit 4b9f0d5

Browse files
committed
Use standardized build data variable names
The Arduino Lint build process defines some variables with values that are used in the `--version` output. These variable names have been modified in the standardized "template" build system, and so must also be modified here.
1 parent e48a1b1 commit 4b9f0d5

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

Diff for: Taskfile.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ vars:
2424
LDFLAGS: >-
2525
-ldflags
2626
'
27-
-X {{.CONFIGURATION_PACKAGE}}.version={{.VERSION}}
28-
-X {{.CONFIGURATION_PACKAGE}}.commit={{.COMMIT}}
29-
-X {{.CONFIGURATION_PACKAGE}}.buildTimestamp={{.TIMESTAMP}}
27+
-X {{.CONFIGURATION_PACKAGE}}.Version={{.VERSION}}
28+
-X {{.CONFIGURATION_PACKAGE}}.Commit={{.COMMIT}}
29+
-X {{.CONFIGURATION_PACKAGE}}.Timestamp={{.TIMESTAMP}}
3030
'
3131
GOFLAGS: "-timeout 10m -v -coverpkg=./... -covermode=atomic"
3232
DOCS_VERSION: dev

Diff for: internal/command/command.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func ArduinoLint(rootCommand *cobra.Command, cliArguments []string) {
3939

4040
if configuration.VersionMode() {
4141
if configuration.OutputFormat() == outputformat.Text {
42-
if configuration.Version() == "" {
43-
fmt.Print("0.0.0+" + configuration.Commit())
42+
if configuration.BuildVersion() == "" {
43+
fmt.Print("0.0.0+" + configuration.BuildCommit())
4444
} else {
45-
fmt.Print(configuration.Version())
45+
fmt.Print(configuration.BuildVersion())
4646
}
4747
fmt.Println(" " + configuration.BuildTimestamp())
4848
} else {
@@ -51,8 +51,8 @@ func ArduinoLint(rootCommand *cobra.Command, cliArguments []string) {
5151
Commit string `json:"commit"`
5252
BuildTimestamp string `json:"buildTimestamp"`
5353
}{
54-
Version: configuration.Version(),
55-
Commit: configuration.Commit(),
54+
Version: configuration.BuildVersion(),
55+
Commit: configuration.BuildCommit(),
5656
BuildTimestamp: configuration.BuildTimestamp(),
5757
}
5858
versionJSON, err := json.MarshalIndent(versionObject, "", " ")

Diff for: internal/configuration/configuration.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -209,25 +209,28 @@ func VersionMode() bool {
209209
return versionMode
210210
}
211211

212-
var version string
212+
// Version is the build version.
213+
var Version string
213214

214-
// Version returns the build version.
215-
func Version() string {
216-
return version
215+
// BuildVersion returns the build version.
216+
func BuildVersion() string {
217+
return Version
217218
}
218219

219-
var commit string
220+
// Commit is the HEAD commit of the Arduino Lint repository when the application was built.
221+
var Commit string
220222

221-
// Commit returns the HEAD commit of the Arduino Lint repository when the application was built.
222-
func Commit() string {
223-
return commit
223+
// BuildCommit returns the HEAD commit of the Arduino Lint repository when the application was built.
224+
func BuildCommit() string {
225+
return Commit
224226
}
225227

226-
var buildTimestamp string
228+
// Timestamp is the timestamp of the build.
229+
var Timestamp string
227230

228231
// BuildTimestamp returns the timestamp of the build.
229232
func BuildTimestamp() string {
230-
return buildTimestamp
233+
return Timestamp
231234
}
232235

233236
var targetPaths paths.PathList

Diff for: internal/configuration/configuration_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,16 @@ func TestInitializeOfficial(t *testing.T) {
244244
}
245245

246246
func TestVersion(t *testing.T) {
247-
version = "42.1.2"
248-
assert.Equal(t, version, Version())
247+
Version = "42.1.2"
248+
assert.Equal(t, Version, BuildVersion())
249249
}
250250

251251
func TestCommit(t *testing.T) {
252-
commit = "abcd"
253-
assert.Equal(t, commit, Commit())
252+
Commit = "abcd"
253+
assert.Equal(t, Commit, BuildCommit())
254254
}
255255

256256
func TestBuildTimestamp(t *testing.T) {
257-
buildTimestamp = "2020-11-27T04:05:19+00:00"
258-
assert.Equal(t, buildTimestamp, BuildTimestamp())
257+
Timestamp = "2020-11-27T04:05:19+00:00"
258+
assert.Equal(t, Timestamp, BuildTimestamp())
259259
}

0 commit comments

Comments
 (0)