Repository: google/go-github
Pull request #2880 (2023-08-16 17:50:21)

Add SubmoduleGitURL to RepositoryContent
Fixes: #2877.

gmlewis: @Parker77 - do you have time for another review, please?
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/google/go-github/pull/2880?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#2880](https://app.codecov.io/gh/google/go-github/pull/2880?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (641ad3e) into [master](https://app.codecov.io/gh/google/go-github/commit/0c562f6a6c3f431426e043f855d8009880d2acf2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (0c562f6) will **not change** coverage.
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##           master    #2880   +/-   ##
=======================================
  Coverage   98.06%   98.06%           
=======================================
  Files         140      140           
  Lines       12269    12269           
=======================================
  Hits        12031    12031           
  Misses        162      162           
  Partials       76       76           
```


| [Files Changed](https://app.codecov.io/gh/google/go-github/pull/2880?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) | Coverage Δ | |
|---|---|---|
| [github/repos\_contents.go](https://app.codecov.io/gh/google/go-github/pull/2880?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#diff-Z2l0aHViL3JlcG9zX2NvbnRlbnRzLmdv) | `87.82% <ø> (ø)` | |



Patch:
diff --git a/github/github-accessors.go b/github/github-accessors.go
index 8e76ff25..562ad734 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/repos_contents.go b/github/repos_contents.go
index e859a4dd..de7a0d5b 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.


Test patch:
diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go
index 6e863e07..0a6b5271 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 925e4563..1d2a47bb 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_test.go b/github/repos_contents_test.go
index 295c2168..ab69b5cd 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",