Skip to content

Commit

Permalink
Add SubmoduleGitURL to RepositoryContent (google#2880)
Browse files Browse the repository at this point in the history
Fixes: google#2877.
  • Loading branch information
gmlewis committed Sep 18, 2023
1 parent 7f48e67 commit 7e6f052
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 45 deletions.
8 changes: 8 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 14 additions & 13 deletions github/github-stringify_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions github/repos_contents.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ type RepositoryContent struct {
// Content contains the actual file content, which may be encoded.
// Callers should call GetContent which will decode the content if
// necessary.
Content *string `json:"content,omitempty"`
SHA *string `json:"sha,omitempty"`
URL *string `json:"url,omitempty"`
GitURL *string `json:"git_url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
DownloadURL *string `json:"download_url,omitempty"`
Content *string `json:"content,omitempty"`
SHA *string `json:"sha,omitempty"`
URL *string `json:"url,omitempty"`
GitURL *string `json:"git_url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
DownloadURL *string `json:"download_url,omitempty"`
SubmoduleGitURL *string `json:"submodule_git_url,omitempty"`
}

// RepositoryContentResponse holds the parsed response from CreateFile, UpdateFile, and DeleteFile.
Expand Down
56 changes: 30 additions & 26 deletions github/repos_contents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,18 +782,19 @@ func TestRepositoryContent_Marshal(t *testing.T) {
testJSONMarshal(t, &RepositoryContent{}, "{}")

r := &RepositoryContent{
Type: String("type"),
Target: String("target"),
Encoding: String("encoding"),
Size: Int(1),
Name: String("name"),
Path: String("path"),
Content: String("content"),
SHA: String("sha"),
URL: String("url"),
GitURL: String("gurl"),
HTMLURL: String("hurl"),
DownloadURL: String("durl"),
Type: String("type"),
Target: String("target"),
Encoding: String("encoding"),
Size: Int(1),
Name: String("name"),
Path: String("path"),
Content: String("content"),
SHA: String("sha"),
URL: String("url"),
GitURL: String("gurl"),
HTMLURL: String("hurl"),
DownloadURL: String("durl"),
SubmoduleGitURL: String("smgurl"),
}

want := `{
Expand All @@ -808,7 +809,8 @@ func TestRepositoryContent_Marshal(t *testing.T) {
"url": "url",
"git_url": "gurl",
"html_url": "hurl",
"download_url": "durl"
"download_url": "durl",
"submodule_git_url": "smgurl"
}`

testJSONMarshal(t, r, want)
Expand All @@ -819,18 +821,19 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) {

r := &RepositoryContentResponse{
Content: &RepositoryContent{
Type: String("type"),
Target: String("target"),
Encoding: String("encoding"),
Size: Int(1),
Name: String("name"),
Path: String("path"),
Content: String("content"),
SHA: String("sha"),
URL: String("url"),
GitURL: String("gurl"),
HTMLURL: String("hurl"),
DownloadURL: String("durl"),
Type: String("type"),
Target: String("target"),
Encoding: String("encoding"),
Size: Int(1),
Name: String("name"),
Path: String("path"),
Content: String("content"),
SHA: String("sha"),
URL: String("url"),
GitURL: String("gurl"),
HTMLURL: String("hurl"),
DownloadURL: String("durl"),
SubmoduleGitURL: String("smgurl"),
},
Commit: Commit{
SHA: String("s"),
Expand Down Expand Up @@ -893,7 +896,8 @@ func TestRepositoryContentResponse_Marshal(t *testing.T) {
"url": "url",
"git_url": "gurl",
"html_url": "hurl",
"download_url": "durl"
"download_url": "durl",
"submodule_git_url": "smgurl"
},
"commit": {
"sha": "s",
Expand Down

0 comments on commit 7e6f052

Please sign in to comment.