Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (setq nb-git-commits-per-file-alist '(()))
- ;; (nb-git-commits-for-file "/tmp/nosuchfile") ;; -> -
- ;; (nb-git-commits-for-file "~/path/to/file/in/a/git/repo") ;; -> nb commits
- (defun nb-git-commits-for-file (file)
- ;; Very fugly shell command but it should get the job done
- (shell-command-to-string
- (concat "cd $(dirname $(realpath " file "))"
- " && git log --oneline $(realpath " file ") 2> /dev/null"
- " | wc -l | tr -d '\n' | sed -e 's/^0$/-/'")))
- ;; (update-nb-git-commits-per-file-alist "/home/e/prjs/hf/project.clj")
- (defun update-nb-git-commits-per-file-alist (file)
- ;; we both update the alist and return the nb of commits for file
- (cdr (car (add-to-list 'nb-git-commits-per-file-alist
- (cons file (nb-git-commits-for-file file))))))
- ;; (find-cached-nb-git-commits-or-update-alist "/tmp/nosuchfile") ;; -> -
- (defun find-cached-nb-git-commits-or-update-alist (file)
- (or (cdr (assoc file nb-git-commits-per-file-alist))
- (update-nb-git-commits-per-file-alist file)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement