Skip to content

Commit 930a582

Browse files
committed
Unified various different instances of the "author" class
1 parent 7536eee commit 930a582

File tree

4 files changed

+70
-55
lines changed

4 files changed

+70
-55
lines changed

src/main/java/org/kohsuke/github/GHCommit.java

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.kohsuke.github;
22

3+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
4+
35
import java.io.IOException;
46
import java.net.URL;
57
import java.util.AbstractList;
68
import java.util.ArrayList;
79
import java.util.Collections;
8-
import java.util.Date;
910
import java.util.List;
1011

1112
/**
@@ -31,11 +32,13 @@ public static class ShortInfo {
3132

3233
private int comment_count;
3334

34-
public GHAuthor getAuthor() {
35+
@WithBridgeMethods(value=GHAuthor.class,castRequired=true)
36+
public GitUser getAuthor() {
3537
return author;
3638
}
3739

38-
public GHAuthor getCommitter() {
40+
@WithBridgeMethods(value=GHAuthor.class,castRequired=true)
41+
public GitUser getCommitter() {
3942
return committer;
4043
}
4144

@@ -50,21 +53,11 @@ public int getCommentCount() {
5053
return comment_count;
5154
}
5255
}
53-
54-
public static class GHAuthor {
55-
private String name,email,date;
5656

57-
public String getName() {
58-
return name;
59-
}
60-
61-
public String getEmail() {
62-
return email;
63-
}
64-
65-
public Date getDate() {
66-
return GitHub.parseDate(date);
67-
}
57+
/**
58+
* @deprecated Use {@link GitUser} instead.
59+
*/
60+
public static class GHAuthor extends GitUser {
6861
}
6962

7063
public static class Stats {

src/main/java/org/kohsuke/github/GHCompare.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.kohsuke.github;
22

3+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
4+
35
import java.net.URL;
46
import java.util.Date;
57

@@ -109,11 +111,13 @@ public String getMessage() {
109111
return message;
110112
}
111113

112-
public User getAuthor() {
114+
@WithBridgeMethods(value=User.class,castRequired=true)
115+
public GitUser getAuthor() {
113116
return author;
114117
}
115118

116-
public User getCommitter() {
119+
@WithBridgeMethods(value=User.class,castRequired=true)
120+
public GitUser getCommitter() {
117121
return committer;
118122
}
119123

@@ -134,23 +138,13 @@ public String getSha() {
134138
}
135139
}
136140

137-
public static class User {
138-
private String name, email, date;
139-
140-
public String getName() {
141-
return name;
142-
}
143-
144-
public String getEmail() {
145-
return email;
146-
}
147-
148-
public Date getDate() {
149-
return GitHub.parseDate(date);
150-
}
141+
/**
142+
* @deprecated use {@link GitUser} instead.
143+
*/
144+
public static class User extends GitUser {
151145
}
152146

153147
public static enum Status {
154-
behind, ahead, identical;
148+
behind, ahead, identical
155149
}
156150
}

src/main/java/org/kohsuke/github/GHPullRequestCommitDetail.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
*/
2424
package org.kohsuke.github;
2525

26+
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
27+
2628
import java.net.URL;
27-
import java.util.Date;
2829

2930
/**
3031
* Commit detail inside a {@link GHPullRequest}.
@@ -33,25 +34,12 @@
3334
*/
3435
public class GHPullRequestCommitDetail {
3536

36-
public static class Authorship {
37-
String name;
38-
String email;
39-
String date;
40-
41-
public String getName() {
42-
return name;
43-
}
44-
45-
public String getEmail() {
46-
return email;
47-
}
48-
49-
public Date getDate() {
50-
return GitHub.parseDate(date);
51-
}
52-
}
37+
/**
38+
* @deprecated Use {@link GitUser}
39+
*/
40+
public static class Authorship extends GitUser {}
5341

54-
public static class Tree {
42+
public static class Tree {
5543
String sha;
5644
String url;
5745

@@ -72,11 +60,13 @@ public static class Commit {
7260
String url;
7361
int comment_count;
7462

75-
public Authorship getAuthor() {
63+
@WithBridgeMethods(value=Authorship.class,castRequired=true)
64+
public GitUser getAuthor() {
7665
return author;
7766
}
7867

79-
public Authorship getCommitter() {
68+
@WithBridgeMethods(value=Authorship.class,castRequired=true)
69+
public GitUser getCommitter() {
8070
return committer;
8171
}
8272

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.kohsuke.github;
2+
3+
import java.util.Date;
4+
5+
/**
6+
* Represents a user in Git who authors/commits a commit.
7+
*
8+
* In contrast, {@link GHUser} is an user of GitHub. Because Git allows a person to
9+
* use multiple e-mail addresses and names when creating a commit, there's generally
10+
* no meaningful mapping between {@link GHUser} and {@link GitUser}.
11+
*
12+
* @author Kohsuke Kawaguchi
13+
*/
14+
public class GitUser {
15+
private String name, email, date;
16+
17+
/**
18+
* Human readable name of the user, such as "Kohsuke Kawaguchi"
19+
*/
20+
public String getName() {
21+
return name;
22+
}
23+
24+
/**
25+
* E-mail address, such as "foo@example.com"
26+
*/
27+
public String getEmail() {
28+
return email;
29+
}
30+
31+
/**
32+
* This field doesn't appear to be consistently available in all the situations where this class
33+
* is used.
34+
*/
35+
public Date getDate() {
36+
return GitHub.parseDate(date);
37+
}
38+
}

0 commit comments

Comments
 (0)