“((foo && bar && baz);最终代码” <-如何无法运行finally代码?

时间:2018-07-15 02:24:22

标签: node.js bash shell

我有此node.js代码,可生成bash脚本:

const k = cp.spawn('bash');

let cmd = [
  `cd ${v.path}`,
  `git checkout "${releaseName}"`,
  `git add .`,
  `git commit -am "modified package.json"`,
  `git checkout master`,
  `( git branch -D -f master_copy_npp_tool &> /dev/null || echo "" ) `,
  `git checkout -b master_copy_npp_tool`,
  `git merge --no-commit -m "This release branch should be merged into master and integration." "${releaseName}"`,
  `git checkout ${releaseName}`,
  `git push -u origin ${releaseName}`
]
.join(' && ');

cmd = `( ${cmd} ); git checkout -f master; `;  // always checkout the integration branch again, at the end

k.stdin.end(cmd);

由于某种原因,脚本将git repo保留在releaseName分支上,而不是master上。

命令作为字符串如下:

( cd /home/rolo/foo
&& git checkout "oleg/npp_tool/release/1531621240127"
&& git add . && git commit -am "modified package.json"
&& git checkout master
&& ( git branch -D -f master_copy_npp_tool &> /dev/null || echo "" )
&& git checkout -b master_copy_npp_tool
&& git merge --no-commit -m "(shortened)." "oleg/npp_tool/release/1531621240127"
&& git checkout oleg/npp_tool/release/1531621240127
&& git push -u origin oleg/npp_tool/release/1531621240127 );
git checkout -f master;

我正在尝试使用最后一个子句:

git checkout -f master; 

作为“最终”块。无论如何,我都希望最终结帐master分支。有人知道怎么了吗?就像我说的那样,它仍然在发布分支上。

基本上我想做的就是这种模式:

( foo && bar && star ); finally-clause;

0 个答案:

没有答案