Skip to content

Commit a945eb7

Browse files
authored
fix(internal): skip write LastGeneratedCommit field to json (#2293)
`last_generated_commit` field should be omitted from all generated JSON request files: release-init-request.json, configure-request.json, generate-request.json, and build-request.json. Ref [language-onboarding.md](https://github.com/googleapis/librarian/blob/main/doc/language-onboarding.md) Fixes #2081
1 parent 58f943a commit a945eb7

File tree

7 files changed

+7
-14
lines changed

7 files changed

+7
-14
lines changed

internal/config/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ type LibraryState struct {
110110
// The last released version of the library, following SemVer.
111111
Version string `yaml:"version" json:"version"`
112112
// The commit hash from the API definition repository at which the library was last generated.
113-
LastGeneratedCommit string `yaml:"last_generated_commit" json:"last_generated_commit"`
113+
LastGeneratedCommit string `yaml:"last_generated_commit" json:"-"`
114114
// The changes from the language repository since the library was last released.
115115
// This field is ignored when writing to state.yaml.
116116
Changes []*conventionalcommits.ConventionalCommit `yaml:"-" json:"changes,omitempty"`

internal/librarian/state_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,8 @@ func TestReadLibraryState(t *testing.T) {
353353
name: "successful load content",
354354
filename: "successful-unmarshal-libraryState.json",
355355
want: &config.LibraryState{
356-
ID: "google-cloud-go",
357-
Version: "1.0.0",
358-
LastGeneratedCommit: "abcd123",
356+
ID: "google-cloud-go",
357+
Version: "1.0.0",
359358
APIs: []*config.API{
360359
{
361360
Path: "google/cloud/compute/v1",

testdata/docker/release-init-request/release-init-request.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{
55
"id": "my-library",
66
"version": "1.1.0",
7-
"last_generated_commit": "",
87
"changes": [
98
{
109
"type": "feat",

testdata/test-read-library-state/successful-unmarshal-libraryState.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"id": "google-cloud-go",
33
"version": "1.0.0",
4-
"last_generated_commit": "abcd123",
54
"apis": [
65
{
76
"path": "google/cloud/compute/v1",
@@ -17,4 +16,4 @@
1716
"remove_regex": [
1817
"example-remove-regex"
1918
]
20-
}
19+
}

testdata/test-read-library-state/unmarshal-libraryState-with-error-msg.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"id": "google-cloud-go",
33
"version": "1.0.0",
4-
"last_generated_commit": "abcd123",
54
"apis": [
65
{
76
"path": "google/cloud/compute/v1",
@@ -12,4 +11,4 @@
1211
"preserve_regex": [],
1312
"remove_regex": [],
1413
"error": "simulated error message"
15-
}
14+
}

testdata/test-write-librarian-state/write-librarian-state-example.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
{
55
"id": "google-cloud-go",
66
"version": "1.0.0",
7-
"last_generated_commit": "abcd123",
87
"apis": [
98
{
109
"path": "google/cloud/compute/v1",
@@ -25,7 +24,6 @@
2524
{
2625
"id": "google-cloud-storage",
2726
"version": "1.2.3",
28-
"last_generated_commit": "",
2927
"apis": [
3028
{
3129
"path": "google/storage/v1",
@@ -38,4 +36,4 @@
3836
"remove_regex": null
3937
}
4038
]
41-
}
39+
}

testdata/test-write-library-state/successful-marshaling-and-writing.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"id": "google-cloud-go",
33
"version": "1.0.0",
4-
"last_generated_commit": "abcd123",
54
"apis": [
65
{
76
"path": "google/cloud/compute/v1",
@@ -18,4 +17,4 @@
1817
"remove_regex": [
1918
"example-remove-regex"
2019
]
21-
}
20+
}

0 commit comments

Comments
 (0)