Skip to content

Commit e3e3371

Browse files
committed
Adding MergeGroupEvent
1 parent 2dab6f5 commit e3e3371

File tree

4 files changed

+272
-0
lines changed

4 files changed

+272
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.activity.events;
22+
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25+
import com.spotify.github.GithubStyle;
26+
import javax.annotation.Nullable;
27+
import org.immutables.value.Value;
28+
29+
/**
30+
* Represents a merge group in GitHub's merge queue.
31+
* A merge group is created when pull requests are added to a merge queue.
32+
*/
33+
@Value.Immutable
34+
@GithubStyle
35+
@JsonSerialize(as = ImmutableMergeGroup.class)
36+
@JsonDeserialize(as = ImmutableMergeGroup.class)
37+
public interface MergeGroup {
38+
39+
/** The SHA of the merge group. */
40+
@Nullable
41+
String headSha();
42+
43+
/** The full ref of the merge group. */
44+
@Nullable
45+
String headRef();
46+
47+
/** The SHA of the merge group's parent commit. */
48+
@Nullable
49+
String baseSha();
50+
51+
/** The full ref of the branch the merge group is merging into. */
52+
@Nullable
53+
String baseRef();
54+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*-
2+
* -\-\-
3+
* github-api
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.activity.events;
22+
23+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
24+
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
25+
import com.spotify.github.GithubStyle;
26+
import javax.annotation.Nullable;
27+
import org.immutables.value.Value;
28+
29+
/**
30+
* Triggered when a pull request is added to a merge queue.
31+
* The merge queue feature allows pull requests to be queued and merged automatically.
32+
*/
33+
@Value.Immutable
34+
@GithubStyle
35+
@JsonSerialize(as = ImmutableMergeGroupEvent.class)
36+
@JsonDeserialize(as = ImmutableMergeGroupEvent.class)
37+
public interface MergeGroupEvent extends BaseEvent {
38+
39+
/**
40+
* The action that was performed. Can be "checks_requested" when a merge group is created
41+
* and checks are requested, or "destroyed" when the merge group is removed from the queue.
42+
*/
43+
@Nullable
44+
String action();
45+
46+
/** The merge group. */
47+
@Nullable
48+
MergeGroup mergeGroup();
49+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*-
2+
* -\-\-
3+
* github-client
4+
* --
5+
* Copyright (C) 2016 - 2020 Spotify AB
6+
* --
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* -/-/-
19+
*/
20+
21+
package com.spotify.github.v3.activity.events;
22+
23+
import static com.google.common.io.Resources.getResource;
24+
import static java.nio.charset.Charset.defaultCharset;
25+
import static org.hamcrest.MatcherAssert.assertThat;
26+
import static org.hamcrest.core.Is.is;
27+
import static org.hamcrest.core.IsNull.notNullValue;
28+
29+
import com.google.common.io.Resources;
30+
import com.spotify.github.jackson.Json;
31+
import java.io.IOException;
32+
import org.junit.jupiter.api.Test;
33+
34+
public class MergeGroupEventTest {
35+
@Test
36+
public void testDeserialization() throws IOException {
37+
String fixture =
38+
Resources.toString(
39+
getResource(this.getClass(), "fixtures/merge_group_event.json"),
40+
defaultCharset());
41+
final MergeGroupEvent mergeGroupEvent =
42+
Json.create().fromJson(fixture, MergeGroupEvent.class);
43+
assertThat(mergeGroupEvent.action(), is("checks_requested"));
44+
assertThat(mergeGroupEvent.mergeGroup(), notNullValue());
45+
assertThat(mergeGroupEvent.mergeGroup().headSha(), is("cd84187b3e9a3e8f5b5f5b5f5b5f5b5f5b5f5b5f"));
46+
assertThat(mergeGroupEvent.mergeGroup().headRef(), is("refs/heads/gh-readonly-queue/main/pr-123-cd84187b3e9a3e8f5b5f5b5f5b5f5b5f5b5f5b5f"));
47+
assertThat(mergeGroupEvent.mergeGroup().baseSha(), is("9049f1265b7d61be4a8904a9a27120d2064dab3b"));
48+
assertThat(mergeGroupEvent.mergeGroup().baseRef(), is("refs/heads/main"));
49+
assertThat(mergeGroupEvent.repository(), notNullValue());
50+
assertThat(mergeGroupEvent.repository().name(), is("public-repo"));
51+
assertThat(mergeGroupEvent.repository().owner().login(), is("baxterthehacker"));
52+
}
53+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"action": "checks_requested",
3+
"merge_group": {
4+
"head_sha": "cd84187b3e9a3e8f5b5f5b5f5b5f5b5f5b5f5b5f",
5+
"head_ref": "refs/heads/gh-readonly-queue/main/pr-123-cd84187b3e9a3e8f5b5f5b5f5b5f5b5f5b5f5b5f",
6+
"base_sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
7+
"base_ref": "refs/heads/main"
8+
},
9+
"repository": {
10+
"id": 35129377,
11+
"name": "public-repo",
12+
"full_name": "baxterthehacker/public-repo",
13+
"owner": {
14+
"login": "baxterthehacker",
15+
"id": 6752317,
16+
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
17+
"gravatar_id": "",
18+
"url": "https://api.github.com/users/baxterthehacker",
19+
"html_url": "https://github.com/baxterthehacker",
20+
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
21+
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
22+
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
23+
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
24+
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
25+
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
26+
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
27+
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
28+
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
29+
"type": "User",
30+
"site_admin": false
31+
},
32+
"private": false,
33+
"html_url": "https://github.com/baxterthehacker/public-repo",
34+
"description": "",
35+
"fork": false,
36+
"url": "https://api.github.com/repos/baxterthehacker/public-repo",
37+
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
38+
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
39+
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
40+
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
41+
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
42+
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
43+
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
44+
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
45+
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
46+
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
47+
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
48+
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
49+
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
50+
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
51+
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
52+
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
53+
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
54+
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
55+
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
56+
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
57+
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
58+
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
59+
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
60+
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
61+
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
62+
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
63+
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
64+
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
65+
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
66+
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
67+
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
68+
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
69+
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
70+
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
71+
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
72+
"deployments_url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments",
73+
"created_at": "2015-05-05T23:40:12Z",
74+
"updated_at": "2016-08-15T17:19:01Z",
75+
"pushed_at": "2016-10-03T23:37:43Z",
76+
"git_url": "git://github.com/baxterthehacker/public-repo.git",
77+
"ssh_url": "[email protected]:baxterthehacker/public-repo.git",
78+
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
79+
"svn_url": "https://github.com/baxterthehacker/public-repo",
80+
"homepage": null,
81+
"size": 233,
82+
"stargazers_count": 2,
83+
"watchers_count": 2,
84+
"language": null,
85+
"has_issues": true,
86+
"has_downloads": true,
87+
"has_wiki": true,
88+
"has_pages": true,
89+
"forks_count": 2,
90+
"mirror_url": null,
91+
"open_issues_count": 5,
92+
"forks": 2,
93+
"open_issues": 5,
94+
"watchers": 2,
95+
"default_branch": "master"
96+
},
97+
"sender": {
98+
"login": "baxterthehacker",
99+
"id": 6752317,
100+
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
101+
"gravatar_id": "",
102+
"url": "https://api.github.com/users/baxterthehacker",
103+
"html_url": "https://github.com/baxterthehacker",
104+
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
105+
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
106+
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
107+
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
108+
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
109+
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
110+
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
111+
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
112+
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
113+
"type": "User",
114+
"site_admin": false
115+
}
116+
}

0 commit comments

Comments
 (0)