Skip to content

Commit 12f7405

Browse files
committed
:add: 增加 deploy 中 extends 参数, 用于继承当前分支名称
1 parent 312c883 commit 12f7405

File tree

3 files changed

+312
-269
lines changed

3 files changed

+312
-269
lines changed

libs/deploy.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ module.exports = isHook => {
2323
return;
2424
}
2525
const gitPath = gitURL.replace(/^git\+/ig, '').split('#')[0];
26-
const gitBranch = deployCfg.branch || gitURL.split('#')[1] || 'master';
26+
let gitBranch = deployCfg.branch || gitURL.split('#')[1] || 'master';
27+
const currBranch = ((shelljs.exec('git rev-parse --abbrev-ref HEAD', { silent: true }) || {}).stdout || '').trim();
28+
if (typeof gitBranch === 'object') {
29+
// 继承当前分支
30+
if (currBranch && gitBranch.extends === true) {
31+
gitBranch = currBranch;
32+
} else if (gitBranch.name) {
33+
gitBranch = gitBranch.name;
34+
} else {
35+
gitBranch = 'master';
36+
}
37+
}
2738
const gitMessage = deployCfg.message && ` | ${deployCfg.message}` || '';
2839

2940
const gitUser = deployCfg.user || {};
@@ -38,7 +49,6 @@ module.exports = isHook => {
3849
if (isHook) {
3950
commitHash = ((shelljs.exec('git rev-parse --verify HEAD', { silent: true }) || {}).stdout || '').trim();
4051
} else {
41-
const currBranch = ((shelljs.exec('git rev-parse --abbrev-ref HEAD', { silent: true }) || {}).stdout || '').trim();
4252
commitHash = ((shelljs.exec(`git rev-parse origin/${currBranch}`, { silent: true }) || {}).stdout || '').trim();
4353
}
4454

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.50",
3+
"version": "0.0.55-beta.1",
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.50",
35+
"@micro-app/core": "^0.0.54",
3636
"chalk": "^2.4.2",
3737
"commander": "^2.19.0",
3838
"opn": "^5.5.0",

0 commit comments

Comments
 (0)