|
5 | 5 | ;; Author: Jason Duncan <[email protected]>
|
6 | 6 | ;; Version: 0.0.1
|
7 | 7 | ;; URL: https://github.com/functionreturnfurnction/dashboard-project-status
|
8 |
| -;; Package-Requires: ((git "0.1.1") (dashboard "1.2.5")) |
| 8 | +;; Package-Requires: ((emacs "24") (git "0.1.1") (dashboard "1.2.5")) |
9 | 9 |
|
10 | 10 | ;; This program is free software: you can redistribute it and/or modify
|
11 | 11 | ;; it under the terms of the GNU General Public License as published by
|
|
31 | 31 | (require 'git)
|
32 | 32 | (require 'dashboard)
|
33 | 33 |
|
34 |
| -(defun git-local-is-behind? () |
| 34 | +(defun dashboard-project-status-git-local-is-behind? () |
35 | 35 | "Return non-nil if current `git-repo' is behind its remote."
|
36 | 36 | (numberp
|
37 | 37 | (string-match-p
|
38 | 38 | (regexp-quote "Your branch is behind")
|
39 | 39 | (git-run "status" "-uno"))))
|
40 | 40 |
|
41 |
| -(defun git-unstaged-files () |
| 41 | +(defun dashboard-project-status-git-unstaged-files () |
42 | 42 | "Return list of unstaged files."
|
43 | 43 | (git--lines
|
44 | 44 | (git-run "diff" "--name-only")))
|
45 | 45 |
|
46 |
| -(defun dashboard-insert-project-status-heading () |
| 46 | +(defun dashboard-project-status-insert-heading () |
47 | 47 | "Insert a heading with project path and whether or not it is behind."
|
48 | 48 | (dashboard-insert-heading "Project ")
|
49 | 49 | (if (functionp 'magit-status)
|
|
58 | 58 | (dashboard-insert-heading git-repo))
|
59 | 59 | (dashboard-insert-heading
|
60 | 60 | (concat
|
61 |
| - (if (git-local-is-behind?) |
| 61 | + (if (dashboard-project-status-git-local-is-behind?) |
62 | 62 | " is behind the remote. (use \"git-pull\" to update)"
|
63 | 63 | " is up-to-date.")
|
64 | 64 | hard-newline)))
|
65 | 65 |
|
66 |
| -(defun dashboard-insert-project-status-body () |
| 66 | +(defun dashboard-project-status-insert-body () |
67 | 67 | "Insert lists of untracked, unstaged, and staged files."
|
68 | 68 | (dolist (section `(("Untracked Files" . ,(git-untracked-files))
|
69 |
| - ("Unstaged Files" . ,(git-unstaged-files)) |
| 69 | + ("Unstaged Files" . ,(dashboard-project-status-git-unstaged-files)) |
70 | 70 | ("Staged Files" . ,(git-staged-files))))
|
71 | 71 | (dashboard-insert-recentf-list
|
72 | 72 | (car section)
|
|
77 | 77 | (concat (file-name-as-directory git-repo) cur))
|
78 | 78 | ret))))))))
|
79 | 79 |
|
80 |
| -(defun dashboard-insert-project-status (project-dir &optional update) |
| 80 | +(defun dashboard-project-status (project-dir &optional update) |
81 | 81 | "Return a function which will insert git status for PROJECT-DIR.
|
82 | 82 | If UPDATE is non-nil, update the remote first with 'git remote update'."
|
83 | 83 | `(lambda (list-size)
|
84 | 84 | (let ((git-repo ,project-dir))
|
85 | 85 | (when ,update (git-run "remote" "update"))
|
86 |
| - (dashboard-insert-project-status-heading) |
87 |
| - (dashboard-insert-project-status-body)))) |
| 86 | + (dashboard-project-status-insert-heading) |
| 87 | + (dashboard-project-status-insert-body)))) |
88 | 88 |
|
89 | 89 | (provide 'dashboard-project-status)
|
90 | 90 | ;;; dashboard-project-status.el ends here
|
0 commit comments