代码之家  ›  专栏  ›  技术社区  ›  T04435

git rebase x运行别名

  •  0
  • T04435  · 技术社区  · 5 年前

    我在试着 exec 在执行 git rebase -i

    pick hash commit_message
    x alias_name
    

    Executing: alias_name
    error: cannot run alias_name: No such file or directory
    warning: execution failed: alias_name
    You can fix the problem, and then run
    
      git rebase --continue
    
    
    alias alias_name='calls a phyton script to run arc command'
    

    如果我在终端上运行别名,它将按预期工作。

    0 回复  |  直到 5 年前
        1
  •  0
  •   chepner    5 年前

    Git不知道您定义的任何别名或shell函数,因此它开始执行给定命令的shell也不知道它们。您需要获取一个包含别名定义的文件,然后根据需要在命令本身中启用别名扩展。

    pick hash commit_message
    x source some_file; shopt -s expand_aliases; alias_name
    

    some_file 包含别名定义。

    alias_name 未定义的命令名。不过,用函数替换别名应该可以。

    func_name () {
      the_script.py arg1 arg2
    }
    

    在可访问的文件中,执行以下操作

    x source some_file; func_name