2017-05-25 83 views
2

我們在此使用第三方代碼審查工具。我的所有同事都使用提供的應用上傳他們的代碼進行審查,但不幸的是,這需要一些剪切和粘貼操作。幸運的是,有一個可用於上傳的命令行版本。根據提交來運行命令

我使用magit在emacs中完成了我的git工作流程的大部分工作,我在想如何設置這些功能,以便在特定的提交時按下特定的組合鍵可以調用命令行exe,傳遞提交散列並更改文本。

任何想法或指示如何去做這件事將非常感激。

回答

2

獲得,當你查看日誌的從點提交哈希可以用類似的信息(在magit-diff.el從magit-show-commit那兒剽竊)來完成:

(defun aec/commit-test (rev &optional args files module) 
    "Visit the revision at point in another buffer. 
If there is no revision at point or with a prefix argument prompt 
for a revision." 
    (interactive 
    (let* ((mcommit (magit-section-when module-commit)) 
      (atpoint (or (and (bound-and-true-p magit-blame-mode) 
          (magit-blame-chunk-get :hash)) 
         mcommit 
         (magit-branch-or-commit-at-point) 
         (magit-tag-at-point)))) 
    (nconc (cons (or (and (not current-prefix-arg) atpoint) 
         (magit-read-branch-or-commit "Show commit" atpoint)) 
        (magit-show-commit--arguments)) 
      (and mcommit (list (magit-section-parent-value 
           (magit-current-section))))))) 
    (message (magit-rev-parse (concat rev "^{commit}")))) 

然後你就可以添加一個選項

Actions 
! Git Subcommand (in topdir) k Gitk 
p Git Subcommand (in pwd)  s Shell command (in topdir) 
b Gitk --branches    S Shell command (in pwd) 
g Git Gui      a aec/test 
:與 magit-define-popup-action

(magit-define-popup-action 'magit-run-popup ?a 
    "aec/test" 
    'aec/commit-test) 

從而產生了彈出