Skip to content

Commit

Permalink
Fixing Model and Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Hauck committed Dec 18, 2017
1 parent 6472aa2 commit 761f40f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
14 changes: 14 additions & 0 deletions src/main/java/se/bjurr/gitchangelog/api/model/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import se.bjurr.gitchangelog.api.model.interfaces.ICommits;

public class Issue implements ICommits, IAuthors, Serializable {

private static final long serialVersionUID = -7571341639024417199L;
private final List<Commit> commits;
private final List<Author> authors;
Expand All @@ -37,6 +38,8 @@ public class Issue implements ICommits, IAuthors, Serializable {

private final boolean hasType;

private final boolean hasDescription;
private final String description;
/** Labels on the issue, for GitHub it may be bug, enhancement, ... */
private final List<String> labels;

Expand All @@ -48,6 +51,7 @@ public Issue(
String name,
String title,
String issue,
String description,
String link,
String type,
List<String> labels) {
Expand All @@ -57,6 +61,8 @@ public Issue(
this.name = checkNotNull(name, "name");
this.title = nullToEmpty(title);
this.hasTitle = !isNullOrEmpty(title);
this.description = nullToEmpty(description);
this.hasDescription = !isNullOrEmpty(description);
this.issue = nullToEmpty(issue);
this.hasIssue = !isNullOrEmpty(issue);
this.link = nullToEmpty(link);
Expand Down Expand Up @@ -107,6 +113,14 @@ public String getType() {
return type;
}

public boolean hasDescription() {
return hasDescription;
}

public String getDescription() {
return description;
}

@Override
public List<Author> getAuthors() {
return authors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import se.bjurr.gitchangelog.internal.settings.SettingsIssue;

public class IssueParser {

private static final Logger LOG = getLogger(IssueParser.class);

private final List<GitCommit> commits;
Expand Down Expand Up @@ -96,7 +97,7 @@ public List<ParsedIssue> parseForIssues(final boolean useIntegrationIfConfigured
final String issueType = null;
final List<String> labels = null;
final ParsedIssue noIssue =
new ParsedIssue(settings.getNoIssueName(), issue, link, title, issueType, labels);
new ParsedIssue(settings.getNoIssueName(), issue, "", link, title, issueType, labels);
if (!parsedIssuePerIssue.containsKey(noIssue.getName())) {
parsedIssuePerIssue.put(noIssue.getName(), noIssue);
}
Expand Down Expand Up @@ -132,6 +133,7 @@ private ParsedIssue createParsedIssue(
return new ParsedIssue( //
issuePattern.getName(), //
matchedIssueString, //
"",
link, //
title, //
issueType, //
Expand Down Expand Up @@ -179,6 +181,7 @@ private ParsedIssue createParsedIssue(
return new ParsedIssue( //
issuePattern.getName(), //
matchedIssue, //
"",
link, //
title, //
issueType, //
Expand All @@ -189,6 +192,7 @@ private ParsedIssue createParsedIssue(
final JiraClient jiraClient, final SettingsIssue issuePattern, final String matchedIssue) {
String link = "";
String title = "";
String desc = "";
String issueType = null;
List<String> labels = null;
try {
Expand All @@ -198,13 +202,15 @@ private ParsedIssue createParsedIssue(
title = jiraIssue.getTitle();
issueType = jiraIssue.getIssueType();
labels = jiraIssue.getLabels();
desc = jiraIssue.getDescription();
}
} catch (final GitChangelogIntegrationException e) {
LOG.error(matchedIssue, e);
}
return new ParsedIssue( //
issuePattern.getName(), //
matchedIssue, //
desc,
link, //
title, //
issueType, //
Expand Down Expand Up @@ -234,6 +240,7 @@ private ParsedIssue createParsedIssue(
return new ParsedIssue( //
issuePattern.getName(), //
matchedIssue, //
"",
link, //
title, //
issueType, //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ public class ParsedIssue implements IGitCommitReferer {
private final String issue;
private final String issueType;
private final List<String> labels;
private final String description;

public ParsedIssue(
String name, String issue, String link, String title, String issueType, List<String> labels) {
String name,
String issue,
String description,
String link,
String title,
String issueType,
List<String> labels) {
this.name = checkNotNull(name, "name");
this.title = emptyToNull(title);
this.issue = issue;
this.link = link;
this.issueType = issueType;
this.labels = labels;
this.description = description;
}

public Optional<String> getTitle() {
Expand Down Expand Up @@ -81,6 +89,10 @@ public String getIssue() {
return issue;
}

public String getDescription() {
return description;
}

public void addCommits(List<GitCommit> commits) {
this.gitCommits.addAll(commits);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ private List<ParsedIssue> reduceParsedIssuesToOnlyGitCommits(
new ParsedIssue(
candidate.getName(),
candidate.getIssue(),
candidate.getDescription(),
candidate.getLink(),
candidate.getTitle().orNull(),
candidate.getIssueType(),
Expand Down Expand Up @@ -209,6 +210,7 @@ public Issue apply(ParsedIssue input) {
input.getName(), //
input.getTitle().or(""), //
input.getIssue(), //
input.getDescription(),
input.getLink(), //
input.getIssueType(), //
input.getLabels());
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/jira-issue-jir-1234.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"labels":[
"label1",
"label2"
],"description": "Description of Issue 1234,..."
],"description": "Description"
}
}
2 changes: 1 addition & 1 deletion src/test/resources/jira-issue-jir-5262.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
},
"labels":[

],"description": "Description of Issue 5262,..."
],"description": "Description"
}
}

0 comments on commit 761f40f

Please sign in to comment.