33const path = require ( 'path' ) ;
44const { fs, _, chalk, Env } = require ( '@micro-app/shared-utils' ) ;
55const CONSTANTS = require ( '../../constants' ) ;
6- const { execGit, execGitSync, getCurrBranch, getGitBranch, getGitUser } = require ( './utils' ) ;
6+ const { execGit, execGitSync, getCurrBranch, getGitBranch, getGitUser, getCommitHash } = require ( './utils' ) ;
77
88function createCNAMEFile ( { deployConfig, deployDir } ) {
99 const cname = deployConfig . cname ;
@@ -61,16 +61,6 @@ function gitPush(api, { args, deployConfig, deployDir, gitURL, gitBranch, commit
6161 return chain ;
6262}
6363
64- function getCommitHash ( api , { currBranch, isHooks } ) {
65- let commitHash = '' ;
66- if ( isHooks ) {
67- commitHash = execGitSync ( [ 'rev-parse' , '--verify' , 'HEAD' ] ) ;
68- } else {
69- commitHash = execGitSync ( [ 'rev-parse' , `origin/${ currBranch } ` ] ) ;
70- }
71- return commitHash ;
72- }
73-
7464function getGitMessage ( api , { deployConfig, commitHash } ) {
7565 let gitMessage = deployConfig . message && ` | ${ deployConfig . message } ` || '' ;
7666 if ( ! gitMessage ) {
@@ -138,8 +128,7 @@ module.exports = async function deployCommit(api, args, deployConfigs) {
138128 logger . throw ( 'Sorry, this script requires git' ) ;
139129 }
140130
141- const isHooks = args . hooks ;
142-
131+ // TODO 迁移到外部,且不中断
143132 return Promise . all ( deployConfigs . map ( async ( deployConfig , index ) => {
144133
145134 const gitURL = deployConfig . url || '' ;
@@ -156,7 +145,7 @@ module.exports = async function deployCommit(api, args, deployConfigs) {
156145
157146 const currBranch = getCurrBranch ( deployConfig ) ;
158147
159- const commitHash = getCommitHash ( api , { currBranch , isHooks } ) ;
148+ const commitHash = getCommitHash ( ) ;
160149 if ( _ . isEmpty ( commitHash ) ) {
161150 logger . warn ( 'Not Found commit Hash!' ) ;
162151 return ;
0 commit comments