From cdc0bb260642de39c18580c9a1351590f7b7725b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 21:58:16 +0200 Subject: [PATCH 1/4] introduce NotifySubjectState --- gitea/notifications.go | 22 +++++++++++++++++----- gitea/notifications_test.go | 11 ++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/gitea/notifications.go b/gitea/notifications.go index de53e2c..57f83b1 100644 --- a/gitea/notifications.go +++ b/gitea/notifications.go @@ -29,11 +29,11 @@ type NotificationThread struct { // NotificationSubject contains the notification subject (Issue/Pull/Commit) type NotificationSubject struct { - Title string `json:"title"` - URL string `json:"url"` - LatestCommentURL string `json:"latest_comment_url"` - Type string `json:"type"` - State StateType `json:"state"` + Title string `json:"title"` + URL string `json:"url"` + LatestCommentURL string `json:"latest_comment_url"` + Type string `json:"type"` + State NotifySubjectState `json:"state"` } // NotifyStatus notification status type @@ -48,6 +48,18 @@ const ( NotifyStatusPinned NotifyStatus = "pinned" ) +// NotifySubjectState reflect state of notification subject +type NotifySubjectState string + +const ( + // NotifySubjectOpen if subject is a pull/issue and is open at the moment + NotifySubjectOpen NotifySubjectState = "open" + // NotifySubjectClosed if subject is a pull/issue and is closed at the moment + NotifySubjectClosed NotifySubjectState = "closed" + // NotifySubjectMerged if subject is a pull and got merged + NotifySubjectMerged NotifySubjectState = "merged" +) + // ListNotificationOptions represents the filter options type ListNotificationOptions struct { ListOptions diff --git a/gitea/notifications_test.go b/gitea/notifications_test.go index da61df4..96abc4b 100644 --- a/gitea/notifications_test.go +++ b/gitea/notifications_test.go @@ -60,6 +60,8 @@ func TestNotifications(t *testing.T) { for _, n := range nList { assert.EqualValues(t, true, n.Unread) assert.EqualValues(t, "Issue", n.Subject.Type) + assert.EqualValues(t, NotifySubjectOpen, nList[0].Subject.State) + assert.EqualValues(t, NotifySubjectOpen, nList[1].Subject.State) if n.Subject.Title == "A Issue" { assert.EqualValues(t, repoA.Name, n.Repository.Name) } else if n.Subject.Title == "B Issue" { @@ -104,8 +106,8 @@ func TestNotifications(t *testing.T) { count, _, err = c.CheckNotifications() assert.NoError(t, err) assert.EqualValues(t, 1, count) - assert.Len(t, nList, 1) - if len(nList) > 0 { + if assert.Len(t, nList, 1) { + assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State) _, err = c.ReadNotification(nList[0].ID) assert.NoError(t, err) } @@ -124,5 +126,8 @@ func TestNotifications(t *testing.T) { assert.NoError(t, err) nList, _, err = c.ListNotifications(ListNotificationOptions{Status: []NotifyStatus{NotifyStatusPinned, NotifyStatusUnread}}) assert.NoError(t, err) - assert.Len(t, nList, 2) + if assert.Len(t, nList, 2) { + assert.EqualValues(t, NotifySubjectClosed, nList[0].Subject.State) + assert.EqualValues(t, NotifySubjectClosed, nList[1].Subject.State) + } } -- 2.40.1 From 933495ea9e402f924b44fdca2f9107f67cbf2581 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 22:12:00 +0200 Subject: [PATCH 2/4] fix disclaimer of old docs --- docs/migrate-v0.11-to-v0.12.md | 6 ++---- docs/migrate-v0.12-to-v0.13.md | 5 ++--- docs/migrate-v0.13-to-v0.14.md | 5 ++--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/docs/migrate-v0.11-to-v0.12.md b/docs/migrate-v0.11-to-v0.12.md index f9273ac..0f9969d 100644 --- a/docs/migrate-v0.11-to-v0.12.md +++ b/docs/migrate-v0.11-to-v0.12.md @@ -1,9 +1,7 @@ # Migration Guide: v0.11 to v0.12 -v0.12.0 introduces a number of breaking changes, throu it should not be hard to -migrate. -Just follow this guid and if issues still ocure ask for help on discord or -feel free to create an issue. +v0.12.0 introduces a number of breaking changes, through which it should not be difficult to migrate. +Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. diff --git a/docs/migrate-v0.12-to-v0.13.md b/docs/migrate-v0.12-to-v0.13.md index 5639295..26371c3 100644 --- a/docs/migrate-v0.12-to-v0.13.md +++ b/docs/migrate-v0.12-to-v0.13.md @@ -1,8 +1,7 @@ # Migration Guide: v0.12 to v0.13 -v0.13.0 introduces a number of breaking changes, throu it should not be hard to migrate. -Just follow this guid and if issues still ocure ask for help on discord or -feel free to create an issue. +v0.13.0 introduces a number of breaking changes, through which it should not be difficult to migrate. +Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. diff --git a/docs/migrate-v0.13-to-v0.14.md b/docs/migrate-v0.13-to-v0.14.md index 1c03f94..e199cd8 100644 --- a/docs/migrate-v0.13-to-v0.14.md +++ b/docs/migrate-v0.13-to-v0.14.md @@ -1,8 +1,7 @@ # Migration Guide: v0.13 to v0.14 -v0.14.0 introduces a number of breaking changes, throu it should not be hard to migrate. -Just follow this guid and if issues still ocure ask for help on discord or -feel free to create an issue. +v0.14.0 introduces a number of breaking changes, through which it should not be difficult to migrate. +Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. -- 2.40.1 From b392ca53eaf073bde7bfd161d00a2d07fbd3361b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 22:16:09 +0200 Subject: [PATCH 3/4] Start Migration guid for v0.15 --- docs/migrate-v0.14-to-v0.15.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docs/migrate-v0.14-to-v0.15.md diff --git a/docs/migrate-v0.14-to-v0.15.md b/docs/migrate-v0.14-to-v0.15.md new file mode 100644 index 0000000..d40e389 --- /dev/null +++ b/docs/migrate-v0.14-to-v0.15.md @@ -0,0 +1,18 @@ +# Migration Guide: v0.14 to v0.15 + +v0.15.0 introduces a number of api changes, through which it should not be difficult to migrate. +Just follow this guid and if you still encounter problems, ask for help on discord or feel free to create an issue. + + + +- [Changed Struct Fields (#520)](#changed-struct-fields) + + + +## Changed Struct Fields + + - the State field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains "open", "closed" and add "merged" + +Pulls: +- [#520 Introduce NotifySubjectState](https://gitea.com/gitea/go-sdk/pulls/520) + -- 2.40.1 From 50d7b47532da4d31f96a6c439401f44515418935 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 30 Jun 2021 22:20:15 +0200 Subject: [PATCH 4/4] add ` --- docs/migrate-v0.14-to-v0.15.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migrate-v0.14-to-v0.15.md b/docs/migrate-v0.14-to-v0.15.md index d40e389..118ad27 100644 --- a/docs/migrate-v0.14-to-v0.15.md +++ b/docs/migrate-v0.14-to-v0.15.md @@ -11,7 +11,7 @@ Just follow this guid and if you still encounter problems, ask for help on disco ## Changed Struct Fields - - the State field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains "open", "closed" and add "merged" + - the `State` field at **NotificationSubject** changed from **StateType** to **NotifySubjectState**, it also contains `"open"`, `"closed"` and add `"merged"` Pulls: - [#520 Introduce NotifySubjectState](https://gitea.com/gitea/go-sdk/pulls/520) -- 2.40.1