From 2fbc00de991948030c11264bea1685c61f953a7f Mon Sep 17 00:00:00 2001 From: Daichi Kudo <45157831+kudoas@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:37:56 +0900 Subject: [PATCH 1/3] chore(docs): update action name and fix (#18) docs: update action name and fix --- action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 9d95836..c4744be 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,12 @@ -name: "Sync GitHub Issue" -description: "Sync GitHub Parent Issue to Child Issue" +name: "Sync Issue Field" +description: "Sync GitHub parent issue's fields to child issue's fields." author: "kudoas" inputs: repository: - description: "Repository name with owner. For example, kudoas/gis'" + description: "Repository name with owner. For example, kudoas/sync-issue-field. Default is the current repository." default: ${{ github.repository }} issue: - description: "The number that identifies the issue. Specify the child issue you wish to synchronize with the parent issue" + description: "The number that identifies the issue. Specify the child issue you wish to synchronize with the parent issue. Default is the current issue." default: ${{ github.event.issue.number }} token: description: "GitHub Token" From 282d275d997b06fe4a0b2e944e27e9cf6f5f2b5b Mon Sep 17 00:00:00 2001 From: Daichi Kudo <45157831+kudoas@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:55:06 +0900 Subject: [PATCH 2/3] fix: use return early (#19) --- main.go | 6 ++++++ query/issue.go | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4361eb3..31e841b 100644 --- a/main.go +++ b/main.go @@ -43,6 +43,7 @@ func main() { }); err != nil { log.Fatalf("failed to get parent issue: %v", err) } + mi := mutate.NewMutationIssue() input := githubv4.UpdateIssueInput{ ID: i.GetIssueID(), @@ -53,7 +54,12 @@ func main() { if err := mi.Mutate(client, context.Background(), input); err != nil { log.Fatalf("failed to update issue: %v", err) } + mp := mutate.NewMutationProject() + projectID := p.GetProjectID() + if projectID == nil { + return + } if err := mp.Mutate(client, githubv4.AddProjectV2ItemByIdInput{ ProjectID: p.GetProjectID(), ContentID: i.GetIssueID(), diff --git a/query/issue.go b/query/issue.go index 13ae0e3..e6dc654 100644 --- a/query/issue.go +++ b/query/issue.go @@ -2,7 +2,7 @@ package query import ( "context" - "fmt" + "log" "os" "github.com/shurcooL/githubv4" @@ -35,6 +35,7 @@ func (i *IssueID) GetIssueID() githubv4.ID { func (i *IssueID) GetParentIssueID() githubv4.ID { if len(i.Repository.Issue.TrackedInIssues.Nodes) == 0 { + log.Println("not found parent issue") os.Exit(0) } return i.Repository.Issue.TrackedInIssues.Nodes[0].ID @@ -100,9 +101,8 @@ func (p *ParentIssue) GetMilestoneID() *githubv4.ID { } func (p *ParentIssue) GetProjectID() githubv4.ID { - println(fmt.Sprintf("%+v", p.Node.Issue.ProjectItems.Nodes)) if len(p.Node.Issue.ProjectItems.Nodes) == 0 { - os.Exit(0) + return nil } return p.Node.Issue.ProjectItems.Nodes[0].Project.ID } From 93eba04cc7a4e3b2a36fb9c4db89c3dfc65d5635 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:26:52 +0900 Subject: [PATCH 3/3] chore(main): release 0.0.7 (#20) --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e21cef..d6ad308 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.0.7](https://github.com/kudoas/sync-issue-field/compare/v0.0.6...v0.0.7) (2024-04-21) + + +### Bug Fixes + +* use return early ([#19](https://github.com/kudoas/sync-issue-field/issues/19)) ([282d275](https://github.com/kudoas/sync-issue-field/commit/282d275d997b06fe4a0b2e944e27e9cf6f5f2b5b)) + ## [0.0.6](https://github.com/kudoas/sync-issue-field/compare/v0.0.5...v0.0.6) (2024-04-21)