我们在此处使用第三方代码审核工具。我的所有同事都使用提供的应用程序上传他们的代码进行审核,但不幸的是,这需要一些剪切和粘贴操作。值得庆幸的是,有一个可用于上传的命令行版本。
我使用magit在emacs中执行git工作流程的大部分工作,我想知道如何设置,以便当我的点在特定提交时,按某个键组合将调用命令行exe,传递在提交哈希和更改文本。
非常感谢任何关于如何做到这一点的想法或指针。
答案 0 :(得分: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}"))))
然后,您可以使用magit-define-popup-action
(magit-define-popup-action 'magit-run-popup ?a
"aec/test"
'aec/commit-test)
导致:
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