From 78cae6e151f29694ebdbd83d05ee0ed7fbfa3c5d Mon Sep 17 00:00:00 2001 From: Karoly Kamaras Date: Tue, 18 Apr 2023 10:11:34 +0200 Subject: [PATCH] Add HeadBranch field to WorkflowJob --- github/actions_workflow_jobs.go | 1 + github/actions_workflow_jobs_test.go | 4 ++++ github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ 4 files changed, 23 insertions(+) diff --git a/github/actions_workflow_jobs.go b/github/actions_workflow_jobs.go index b7130916fe..1f018b3e48 100644 --- a/github/actions_workflow_jobs.go +++ b/github/actions_workflow_jobs.go @@ -28,6 +28,7 @@ type WorkflowJob struct { RunID *int64 `json:"run_id,omitempty"` RunURL *string `json:"run_url,omitempty"` NodeID *string `json:"node_id,omitempty"` + HeadBranch *string `json:"head_branch,omitempty"` HeadSHA *string `json:"head_sha,omitempty"` URL *string `json:"url,omitempty"` HTMLURL *string `json:"html_url,omitempty"` diff --git a/github/actions_workflow_jobs_test.go b/github/actions_workflow_jobs_test.go index 521e401102..8cea954500 100644 --- a/github/actions_workflow_jobs_test.go +++ b/github/actions_workflow_jobs_test.go @@ -246,6 +246,7 @@ func TestWorkflowJob_Marshal(t *testing.T) { RunID: Int64(1), RunURL: String("r"), NodeID: String("n"), + HeadBranch: String("b"), HeadSHA: String("h"), URL: String("u"), HTMLURL: String("h"), @@ -274,6 +275,7 @@ func TestWorkflowJob_Marshal(t *testing.T) { "run_id": 1, "run_url": "r", "node_id": "n", + "head_branch": "b", "head_sha": "h", "url": "u", "html_url": "h", @@ -309,6 +311,7 @@ func TestJobs_Marshal(t *testing.T) { RunID: Int64(1), RunURL: String("r"), NodeID: String("n"), + HeadBranch: String("b"), HeadSHA: String("h"), URL: String("u"), HTMLURL: String("h"), @@ -342,6 +345,7 @@ func TestJobs_Marshal(t *testing.T) { "run_id": 1, "run_url": "r", "node_id": "n", + "head_branch": "b", "head_sha": "h", "url": "u", "html_url": "h", diff --git a/github/github-accessors.go b/github/github-accessors.go index eea7518cba..0e25c7e812 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -21798,6 +21798,14 @@ func (w *WorkflowJob) GetCreatedAt() Timestamp { return *w.CreatedAt } +// GetHeadBranch returns the HeadBranch field if it's non-nil, zero value otherwise. +func (w *WorkflowJob) GetHeadBranch() string { + if w == nil || w.HeadBranch == nil { + return "" + } + return *w.HeadBranch +} + // GetHeadSHA returns the HeadSHA field if it's non-nil, zero value otherwise. func (w *WorkflowJob) GetHeadSHA() string { if w == nil || w.HeadSHA == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 5b2054bfeb..8560b2769e 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -25481,6 +25481,16 @@ func TestWorkflowJob_GetCreatedAt(tt *testing.T) { w.GetCreatedAt() } +func TestWorkflowJob_GetHeadBranch(tt *testing.T) { + var zeroValue string + w := &WorkflowJob{HeadBranch: &zeroValue} + w.GetHeadBranch() + w = &WorkflowJob{} + w.GetHeadBranch() + w = nil + w.GetHeadBranch() +} + func TestWorkflowJob_GetHeadSHA(tt *testing.T) { var zeroValue string w := &WorkflowJob{HeadSHA: &zeroValue}