release-it 19.2.0 → 19.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/plugin/GitBase.js +13 -3
- package/lib/plugin/git/Git.js +0 -6
- package/lib/plugin/git/prompts.js +5 -2
- package/lib/util.js +2 -1
- package/package.json +1 -1
package/lib/plugin/GitBase.js
CHANGED
|
@@ -32,16 +32,26 @@ class GitBase extends Plugin {
|
|
|
32
32
|
return latestTag ? latestTag.replace(prefix, '').replace(/^v/, '') : null;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
async getCommitsSinceLatestTag(commitsPath = '') {
|
|
36
|
+
const latestTagName = await this.getLatestTagName();
|
|
37
|
+
const ref = latestTagName ? `${latestTagName}..HEAD` : 'HEAD';
|
|
38
|
+
return this.exec(`git rev-list ${ref} --count ${commitsPath ? `-- ${commitsPath}` : ''}`, { options }).then(Number);
|
|
39
|
+
}
|
|
40
|
+
|
|
35
41
|
async getChangelog() {
|
|
36
42
|
const { snapshot } = this.config.getContext();
|
|
37
43
|
const { latestTag, secondLatestTag } = this.config.getContext();
|
|
38
44
|
const context = { latestTag, from: latestTag, to: 'HEAD' };
|
|
39
|
-
const { changelog } = this.options;
|
|
45
|
+
const { changelog, commit } = this.options;
|
|
40
46
|
if (!changelog) return null;
|
|
41
47
|
|
|
42
48
|
if (latestTag && !this.config.isIncrement) {
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
if ((await this.getCommitsSinceLatestTag()) === 0) {
|
|
50
|
+
context.from = secondLatestTag;
|
|
51
|
+
context.to = `${latestTag}^1`;
|
|
52
|
+
} else if (commit === false) {
|
|
53
|
+
context.to = 'HEAD^1';
|
|
54
|
+
}
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
// For now, snapshots do not get a changelog, as it often goes haywire (easy to add to release manually)
|
package/lib/plugin/git/Git.js
CHANGED
|
@@ -130,12 +130,6 @@ class Git extends GitBase {
|
|
|
130
130
|
);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
async getCommitsSinceLatestTag(commitsPath = '') {
|
|
134
|
-
const latestTagName = await this.getLatestTagName();
|
|
135
|
-
const ref = latestTagName ? `${latestTagName}..HEAD` : 'HEAD';
|
|
136
|
-
return this.exec(`git rev-list ${ref} --count ${commitsPath ? `-- ${commitsPath}` : ''}`, { options }).then(Number);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
133
|
async getUpstreamArgs(pushRepo) {
|
|
140
134
|
if (pushRepo && !this.isRemoteName(pushRepo)) {
|
|
141
135
|
// Use (only) `pushRepo` if it's configured and looks like a url
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { format, truncateLines } from '../../util.js';
|
|
1
|
+
import { format, truncateLines, fixArgs } from '../../util.js';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
commit: {
|
|
5
5
|
type: 'confirm',
|
|
6
|
-
message: context =>
|
|
6
|
+
message: context => {
|
|
7
|
+
if (fixArgs(context.git.commitArgs).includes('--amend')) return 'Amend commit?';
|
|
8
|
+
return `Commit (${truncateLines(format(context.git.commitMessage, context), 1, ' [...]')})?`;
|
|
9
|
+
},
|
|
7
10
|
default: true
|
|
8
11
|
},
|
|
9
12
|
tag: {
|
package/lib/util.js
CHANGED
|
@@ -63,7 +63,8 @@ export const getSystemInfo = () => {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export const format = (template = '', context = {}) => {
|
|
66
|
-
if (!
|
|
66
|
+
if (!template || typeof template !== 'string') return '';
|
|
67
|
+
if (!context || context === null || template.indexOf('${') === -1) return template;
|
|
67
68
|
const log = new Log();
|
|
68
69
|
try {
|
|
69
70
|
return eta.renderString(template, context);
|