Skip to content

Commit bc2ce94

Browse files
author
Jason Duncan
committed
-m Initial commit.
0 parents  commit bc2ce94

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

dashboard-project-status.el

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
;;; dashboard-project-status.el --- Display a git project status in a dashboard widget. -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2019 Jason Duncan, all rights reserved
4+
5+
;; Author: Jason Duncan <[email protected]>
6+
;; Version: 0.0.1
7+
;; URL: https://github.com/functionreturnfurnction/dashboard-project-status
8+
;; Package-Requires: ((git "0.1.1"))
9+
10+
;; This program is free software: you can redistribute it and/or modify
11+
;; it under the terms of the GNU General Public License as published by
12+
;; the Free Software Foundation, either version 3 of the License, or (at
13+
;; your option) any later version.
14+
15+
;; This program is distributed in the hope that it will be useful, but
16+
;; WITHOUT ANY WARRANTY; without even the implied warranty of
17+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18+
;; General Public License for more details.
19+
20+
;; You should have received a copy of the GNU General Public License
21+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
22+
23+
;;; Commentary:
24+
25+
;; Display a git project status in a dashboard widget.
26+
27+
;;; Code:
28+
29+
(require 'git)
30+
31+
(defun git-local-is-behind? ()
32+
(numberp
33+
(string-match-p
34+
(regexp-quote "Your branch is behind")
35+
(git-run "status" "-uno"))))
36+
37+
(defun check-git-project-status (&optional project-dir)
38+
"Update the remote and check the status of PROJECT-DIR."
39+
(let* ((project-dir
40+
(fix-os-path
41+
(concat
42+
(expand-file-name
43+
(or project-dir user-emacs-directory))))))
44+
(with-temp-buffer
45+
(call-process "git" nil nil nil "-C" project-dir "remote" "update")
46+
(call-process "git" nil t nil "-C" project-dir "status" "-uno")
47+
(buffer-string))))
48+
49+
(defun dashboard-insert-project-status-heading ()
50+
(insert
51+
(concat "Project "
52+
git-repo
53+
(if (git-local-is-behind?)
54+
" is behind the remote. (use \"git-pull\" to update)"
55+
"is up-to-date."))))
56+
57+
(defun dashboard-insert-project-status-body ()
58+
59+
60+
(defun dashboard-insert-project-status (project-dir)
61+
(let ((git-repo project-dir))
62+
(lambda (list-size)
63+
(dashboard-insert-project-status-heading)
64+
(dashboard-insert-project-status-body))))
65+
66+
(provide 'dashboard-project-status)
67+
;;; dashboard-project-status.el ends here

dashboard-project-status.el~

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
;;; dashboard-project-status.el --- Display a git project status in a dashboard widget -*- lexical-binding: t; -*-
2+
;;
3+
;; Filename: dashboard-project-status.el
4+
;; Description:
5+
;; Author:
6+
;; Maintainer:
7+
;; Created: Thu Jan 31 12:31:28 2019 (-0500)
8+
;; Version:
9+
;; Package-Requires: ()
10+
;; Last-Updated: Thu Jan 31 12:32:15 2019 (-0500)
11+
;; By: jason
12+
;; Update #: 1
13+
;; URL:
14+
;; Doc URL:
15+
;; Keywords:
16+
;; Compatibility:
17+
;;
18+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19+
;;
20+
;;; Commentary:
21+
;;
22+
;;
23+
;;
24+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25+
;;
26+
;;; Change Log:
27+
;;
28+
;;
29+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30+
;;
31+
;; This program is free software: you can redistribute it and/or modify
32+
;; it under the terms of the GNU General Public License as published by
33+
;; the Free Software Foundation, either version 3 of the License, or (at
34+
;; your option) any later version.
35+
;;
36+
;; This program is distributed in the hope that it will be useful, but
37+
;; WITHOUT ANY WARRANTY; without even the implied warranty of
38+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39+
;; General Public License for more details.
40+
;;
41+
;; You should have received a copy of the GNU General Public License
42+
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
43+
;;
44+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45+
;;
46+
;;; Code:
47+
48+
49+
50+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51+
;;; dashboard-project-status.el ends here

test/dashboard-project-status-test.el

Whitespace-only changes.

test/test-helper.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
;; -*- lexical-binding: t; -*-
2+
3+
(when (require 'undercover nil t)
4+
(undercover "*.el"
5+
(:exclude "*-tests.el")))
6+
7+
(require 'format-table)

0 commit comments

Comments
 (0)