Phabricator的arcanist在windows下执行arc feature(branch)异常问题的hack修正方法

首先,发现问题的arcanist版本如下:

arc version
arcanist d92fa96366c0ed50e4257508148aa75192d4fb1f (20 Jun 2019)
libphutil b416093386a225b1d9a2de906899b94cbf4babcb (8 Jul 2019)

错误现象为执行arc featurearc branch时,提示:

[2019-07-20 13:30:05] ERROR 8: Undefined offset: 1 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 2 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 3 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 4 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
[2019-07-20 13:30:05] ERROR 8: Undefined offset: 5 at [D:\phabricator\arcanist\src\repository\api\ArcanistGitAPI.php:1094]
arcanist(head=master, ref.master=d92fa96366c0), phutil(head=master, ref.master=b416093386a2)
  #0 ArcanistGitAPI::getAllBranches() called at [<arcanist>\src\workflow\ArcanistFeatureWorkflow.php:89]
  #1 ArcanistFeatureWorkflow::run() called at [<arcanist>\scripts\arcanist.php:394]
Usage Exception: No branches in this working copy.

加入–trace后,定位到了出错的php代码,搜索后发现官方早就有人提出了这个问题: https://secure.phabricator.com/T8821 ,而且也指出了问题根源,即%百分号触发了转义导致,具体到这个错误就是在ArcanistGitAPI.php:1094的所属函数getAllBranches里,构造git for-each-ref –format=这个shell命令的时候里面format参数被转乱了,直接按照官方链接里面提出的hack方法,修改php代码为:

    list($stdout) = $this->execxLocal(
      'for-each-ref --format="%C" -- refs/heads',
      implode('%01', $field_list));

修改原来的–format=%s为–format=”%C”,即可临时解决。

博主友情提示:

如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用>>博主专用加密工具v3<<处理后发布,原文只有博主可以看到。