looking for a text editor which automates git commits upon closing the file

  • A+
Category:Languages

I have also posted this question here on Reddit

I'm not a version control or Git expert and it is very cumbersome for me to do all the steps manually. I want to have a text editor which uplon closing the file, if any changes were applied, applies these commands:

  • checks if the file has been edited
  • git add <filename>
  • opens a popup or tab to edit the commit message
  • git commit -m "the commit message entered in the popup"

I would appreciate if you could help me know if there is such an editor to have this feature built in or via a plugin/addon. Or if it is possible to write such a plugin.

P.S.1. It doesn't really have to be git, mercurial or other versions control systems are also fine.

P.S.2. I think this should be doable in Vim script and/or emacs lisp, If I knew those languages.

P.S.3. here and here different ideas have been discussed. It is apparently possible to git commit upon closing, but I want to write the message manually.

 


It should definitely be doable in any reasonably programmable editor.

Here, for example, is a definitely very buggy and incomplete first stab at a hook for Emacs + magit:

(defun my/auto-commit-on-kill ()   (when buffer-file-name     (let* ((current (magit-file-relative-name))            (choices (nconc (magit-modified-files) (magit-untracked-files)))            (to-stage (car (member current choices))))       (when to-stage         (magit-stage-file to-stage)         (magit-commit)))))  (add-hook 'kill-buffer-hook 'my/auto-commit-on-kill) 

But actually if you were to go the Emacs/magit route I would strongly urge you to just use magit "manually". It's really not that complicated and yet it would teach you way more about git than relying on a even more simplified interface.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: