Skip to content

Commit ed069be

Browse files
committed
:add: deploy commit message
1 parent 1c8fe2b commit ed069be

File tree

4 files changed

+743
-605
lines changed

4 files changed

+743
-605
lines changed

libs/deploy.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports = isHook => {
3535
gitBranch = 'master';
3636
}
3737
}
38-
const gitMessage = deployCfg.message && ` | ${deployCfg.message}` || '';
38+
let gitMessage = deployCfg.message && ` | ${deployCfg.message}` || '';
3939

4040
const gitUser = deployCfg.user || {};
4141
if (!gitUser.name || typeof gitUser.name !== 'string') {
@@ -57,6 +57,13 @@ module.exports = isHook => {
5757
return;
5858
}
5959

60+
if (!gitMessage) {
61+
const msg = ((shelljs.exec(`git log --pretty=format:“%s” ${commitHash} -1`, { silent: true }) || {}).stdout || '').trim();
62+
if (msg) {
63+
gitMessage = ` | ${msg}`;
64+
}
65+
}
66+
6067
const gitRoot = path.resolve(microAppConfig.root, '.git');
6168
if (fs.statSync(gitRoot).isDirectory()) {
6269
const deployDir = path.resolve(gitRoot, 'micro-deploy');
@@ -108,7 +115,7 @@ module.exports = isHook => {
108115
shelljs.exec(`git config user.email ${gitUser.email}`, { silent: true, cwd: deployDir });
109116
}
110117
// commit + push
111-
const { code } = shelljs.exec(`git commit -a -m ":package: auto deploy ${MICRO_APP_CONFIG_NAME} - ${commitHash.substr(0, 8)}${gitMessage}"`, { cwd: deployDir });
118+
const { code } = shelljs.exec(`git commit -a -m ":package: auto deploy ${MICRO_APP_CONFIG_NAME} - ${currBranch} - ${commitHash.substr(0, 8)}${gitMessage}"`, { cwd: deployDir });
112119
if (code === 0) {
113120
const { code } = shelljs.exec('git push', { cwd: deployDir });
114121
if (code === 0) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@micro-app/cli",
3-
"version": "0.0.56-beta.1",
3+
"version": "0.0.57",
44
"description": "micro app cli",
55
"bin": {
66
"micro-app": "./bin/micro-app.js",
@@ -32,7 +32,7 @@
3232
"eslint-config-2o3t": "^1.1.17"
3333
},
3434
"dependencies": {
35-
"@micro-app/core": "^0.0.56-beta.1",
35+
"@micro-app/core": "^0.0.57",
3636
"chalk": "^2.4.2",
3737
"commander": "^2.19.0",
3838
"opn": "^5.5.0",

test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

3-
// const deploy = require('../libs/deploy');
4-
// deploy();
3+
const deploy = require('../libs/deploy');
4+
deploy();
55

66

7-
const microApp = require('../bin/micro-app-dev');
7+
// const microApp = require('../bin/micro-app-dev');

0 commit comments

Comments
 (0)