Skip to content

Commit 16a86d5

Browse files
Add getComment() to ChangeLogSet.Entry
1 parent 396f78b commit 16a86d5

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

core/src/main/java/hudson/scm/ChangeLogSet.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ public long getTimestamp() {
197197
@Exported
198198
public abstract String getMsg();
199199

200+
/**
201+
* Returns the comment for this change entry.
202+
* By default, returns the same value as {@link #getMsg()}.
203+
*
204+
* @since 2.552
205+
*/
206+
@Exported
207+
public String getComment() {
208+
return getMsg();
209+
}
210+
200211
/**
201212
* The user who made this change.
202213
*
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package hudson.scm;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import hudson.model.User;
6+
import java.util.Collection;
7+
import java.util.Collections;
8+
import org.junit.jupiter.api.Test;
9+
10+
public class ChangeLogSetEntryTest {
11+
12+
@Test
13+
public void getCommentDefaultsToMsg() {
14+
ChangeLogSet.Entry entry = new ChangeLogSet.Entry() {
15+
16+
@Override
17+
public String getMsg() {
18+
return "short message";
19+
}
20+
21+
@Override
22+
public User getAuthor() {
23+
return User.getOrCreateByIdOrFullName("test-user");
24+
}
25+
26+
@Override
27+
public Collection<String> getAffectedPaths() {
28+
return Collections.emptyList();
29+
}
30+
};
31+
32+
assertEquals("short message", entry.getComment());
33+
}
34+
35+
@Test
36+
public void getCommentCanBeOverridden() {
37+
ChangeLogSet.Entry entry = new ChangeLogSet.Entry() {
38+
39+
@Override
40+
public String getMsg() {
41+
return "short";
42+
}
43+
44+
@Override
45+
public String getComment() {
46+
return "full commit message";
47+
}
48+
49+
@Override
50+
public User getAuthor() {
51+
return User.getOrCreateByIdOrFullName("testest-user");
52+
}
53+
54+
@Override
55+
public Collection<String> getAffectedPaths() {
56+
return Collections.emptyList();
57+
}
58+
};
59+
60+
assertEquals("full commit message", entry.getComment());
61+
}
62+
}

0 commit comments

Comments
 (0)