diff --git a/github/github-accessors.go b/github/github-accessors.go index 8e76ff2583e..562ad734562 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -18638,6 +18638,14 @@ func (r *RepositoryContent) GetSize() int { return *r.Size } +// GetSubmoduleGitURL returns the SubmoduleGitURL field if it's non-nil, zero value otherwise. +func (r *RepositoryContent) GetSubmoduleGitURL() string { + if r == nil || r.SubmoduleGitURL == nil { + return "" + } + return *r.SubmoduleGitURL +} + // GetTarget returns the Target field if it's non-nil, zero value otherwise. func (r *RepositoryContent) GetTarget() string { if r == nil || r.Target == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 6e863e0778d..0a6b5271e8b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -21705,6 +21705,16 @@ func TestRepositoryContent_GetSize(tt *testing.T) { r.GetSize() } +func TestRepositoryContent_GetSubmoduleGitURL(tt *testing.T) { + var zeroValue string + r := &RepositoryContent{SubmoduleGitURL: &zeroValue} + r.GetSubmoduleGitURL() + r = &RepositoryContent{} + r.GetSubmoduleGitURL() + r = nil + r.GetSubmoduleGitURL() +} + func TestRepositoryContent_GetTarget(tt *testing.T) { var zeroValue string r := &RepositoryContent{Target: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 925e4563c0e..1d2a47bbffe 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -1683,20 +1683,21 @@ func TestRepositoryCommit_String(t *testing.T) { func TestRepositoryContent_String(t *testing.T) { v := RepositoryContent{ - Type: String(""), - Target: String(""), - Encoding: String(""), - Size: Int(0), - Name: String(""), - Path: String(""), - Content: String(""), - SHA: String(""), - URL: String(""), - GitURL: String(""), - HTMLURL: String(""), - DownloadURL: String(""), + Type: String(""), + Target: String(""), + Encoding: String(""), + Size: Int(0), + Name: String(""), + Path: String(""), + Content: String(""), + SHA: String(""), + URL: String(""), + GitURL: String(""), + HTMLURL: String(""), + DownloadURL: String(""), + SubmoduleGitURL: String(""), } - want := `github.RepositoryContent{Type:"", Target:"", Encoding:"", Size:0, Name:"", Path:"", Content:"", SHA:"", URL:"", GitURL:"", HTMLURL:"", DownloadURL:""}` + want := `github.RepositoryContent{Type:"", Target:"", Encoding:"", Size:0, Name:"", Path:"", Content:"", SHA:"", URL:"", GitURL:"", HTMLURL:"", DownloadURL:"", SubmoduleGitURL:""}` if got := v.String(); got != want { t.Errorf("RepositoryContent.String = %v, want %v", got, want) } diff --git a/github/repos_contents.go b/github/repos_contents.go index e859a4ddca4..de7a0d5b82b 100644 --- a/github/repos_contents.go +++ b/github/repos_contents.go @@ -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. diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 295c21684cd..ab69b5cdcbb 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -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 := `{ @@ -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) @@ -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"), @@ -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",