Skip to content

Commit 537b2de

Browse files
author
fulin
committed
fix: 错误数据改动
1 parent 9d6f93c commit 537b2de

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

src/main/java/com/fulinlin/constant/GitCommitConstants.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
* @create: 2019-12-08 11:37
77
**/
88
public class GitCommitConstants {
9-
public static final String DEFAULT_TEMPLATE = "${type}(${scope}): ${subject}\n" +
9+
public static final String DEFAULT_TEMPLATE = "#if($type)${type}#end#if(${scope})(${scope})#end: #if(${subject})${subject}#end\n" +
1010
"\n" +
11-
"${body}\n" +
11+
"#if(${body})${body}#end\n" +
1212
"\n" +
13-
"BREAKING CHANGE: ${changes}\n" +
13+
"#if(${changes})BREAKING CHANGE: ${changes}#end\n" +
1414
"\n" +
15-
"Closes ${closes}\n";
15+
"#if(${closes})Closes ${closes}#end\n";
1616

1717
}

src/main/java/com/fulinlin/ui/CommitMessage.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.fulinlin.model.TypeAlias;
66
import com.fulinlin.storage.GitCommitMessageHelperSettings;
77
import com.fulinlin.utils.VelocityUtils;
8+
import com.intellij.openapi.util.text.StringUtil;
9+
import org.apache.commons.lang.StringUtils;
810
import org.apache.commons.lang.WordUtils;
911

1012
import static org.apache.commons.lang.StringUtils.isNotBlank;
@@ -38,12 +40,26 @@ private String buildContent(GitCommitMessageHelperSettings settings,
3840
) {
3941

4042
CommitTemplate commitTemplate = new CommitTemplate();
41-
commitTemplate.setType(typeAlias.toString());
42-
commitTemplate.setScope(changeScope);
43-
commitTemplate.setSubject(shortDescription);
44-
commitTemplate.setBody(longDescription);
45-
commitTemplate.setChanges(breakingChanges);
46-
commitTemplate.setCloses(closedIssues);
43+
if (typeAlias != null) {
44+
if (StringUtils.isNotBlank(typeAlias.getTitle())) {
45+
commitTemplate.setType(typeAlias.getTitle());
46+
}
47+
}
48+
if (StringUtils.isNotBlank(changeScope)) {
49+
commitTemplate.setScope(changeScope);
50+
}
51+
if (StringUtils.isNotBlank(shortDescription)) {
52+
commitTemplate.setSubject(shortDescription);
53+
}
54+
if (StringUtils.isNotBlank(longDescription)) {
55+
commitTemplate.setBody(longDescription);
56+
}
57+
if (StringUtils.isNotBlank(breakingChanges)) {
58+
commitTemplate.setChanges(breakingChanges);
59+
}
60+
if (StringUtils.isNotBlank(closedIssues)) {
61+
commitTemplate.setCloses(closedIssues);
62+
}
4763
String template = settings.getDateSettings().getTemplate();
4864
return VelocityUtils.convert(template, commitTemplate);
4965
}
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
#set($directoryRoot = "www" )
2-
#set($templateName = "index.vm" )
3-
#set($template = "$directoryRoot/$templateName" )
1+
#if($type)${type}#end#if(${scope})(${scope})#end: #if(${subject})${subject}#end
42

5-
feat(scope): dep
6-
7-
xzcxz
8-
9-
BREAKING CHANGE: ccccc
10-
11-
Closes #22
12-
13-
14-
${type}(${scopr}): ${subject}
15-
16-
${body}
17-
18-
BREAKING CHANGE: ${changes}
19-
20-
Closes ${closes}
3+
#if(${body})${body}#end
214

5+
#if(${changes})BREAKING CHANGE: ${changes}#end
226

7+
#if(${closes})Closes ${closes}#end

0 commit comments

Comments
 (0)