Codebase list emacs-git-messenger / 943e2d8
New upstream version 0.18 Lev Lamberov 7 years ago
10 changed file(s) with 682 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 /.cask/
1 *.elc
0 language: generic
1 sudo: false
2 before_install:
3 - curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
4 - evm install $EVM_EMACS --use --skip
5 - cask
6 env:
7 - EVM_EMACS=emacs-24.4-travis
8 - EVM_EMACS=emacs-24.5-travis
9 - EVM_EMACS=emacs-25.1-travis
10 script:
11 - emacs --version
12 - make test
0 (source gnu)
1 (source melpa)
2
3 (package-file "git-messenger.el")
4
5 (development
6 (depends-on "magit"))
0 Revision history for git-messenger.el
1
2 Revision 0.18 2017/01/01 syohex
3 - Drop older Emacs support
4 - Implement magit integration
5
6 Revision 0.17 2016/08/16 syohex
7 - Initial support going parent commit(#40)
8 - Show command keys in prompt(#39)
9 - Improve deciding VCS type(#38)
10 - Support merurial(#37 Thanks Sean Farley!!)
11 - Enable view-mode(#36)
12
13 Revision 0.16 2015/03/14 syohex
14 - Support Subversion
15
16 Revision 0.15 2014/08/29 syohex
17 - Improve quit command.
18 Thanks tsdh !!
19
20 Revision 0.14 2014/08/10 syohex
21 - Fix customizable variable type
22 Thanks conleym !!
23
24 Revision 0.13 2014/07/06 syohex
25 - Refactoring
26 - Improve for tramp
27
28 Revision 0.12 2014/05/25 syohex
29 - Improve for tramp
30
31 Revision 0.11 2014/04/02 syohex
32 - Fix some bugs
33 - restore popup-ed buffer mode
34 - set git option for working correctly in Emacs
35
36 Revision 0.10 2014/04/02 syohex
37 - Support 'git diff' and 'git show' command
38
39 Revision 0.09 2014/04/02 syohex
40 - Support key mapping(Thanks stsquad)
41
42 Revision 0.08 2014/01/17 syohex
43 - Only documentation change
44
45 Revision 0.07 2014/01/14 syohex
46 - Fix double escaping issue(#13)
47 Reported by achitu
48
49 Revision 0.06 2014/01/09 syohex
50 - Support TRAMP
51
52 Revision 0.05 2013/07/18 syohex
53 - add git-messenger:before-popup-hook
54 - fix case core.autocrlf=true or input(Reported by redguardtoo)
55
56 Revision 0.04 2013/06/13 syohex
57 - Refactoring
58 rename confused variable name
59
60 Revision 0.03 2013/06/13 syohex
61 - Support showing detail(Advice by redguardtoo)
62
63 Revision 0.02 2013/06/11 syohex
64 - Support not committed line(Thanks @stsquad, @percell)
65 - Shell Quote file name
66
67 Revision 0.01 2013/06/11 syohex
68 - Initial version
0 .PHONY : test
1
2 EMACS ?= emacs
3 CASK ?= cask
4
5 LOADPATH = -L .
6
7 ELPA_DIR = $(shell EMACS=$(EMACS) $(CASK) package-directory)
8
9 test: elpa
10 $(CASK) exec $(EMACS) -Q -batch $(LOADPATH) \
11 -l test/test.el \
12 -f ert-run-tests-batch-and-exit
13
14 elpa: $(ELPA_DIR)
15 $(ELPA_DIR): Cask
16 $(CASK) install
17 touch $@
0 # git-messenger.el [![melpa badge][melpa-badge]][melpa-link] [![melpa stable badge][melpa-stable-badge]][melpa-stable-link]
1
2 `git-messenger.el` is Emacs port of [git-messenger.vim](https://github.com/rhysd/git-messenger.vim).
3
4 `git-messenger.el` provides function that popup commit message at current line.
5 This is useful when you want to know why this line was changed.
6
7
8 ## Screenshot
9
10 ![Screenshot of git-messenger.el](image/git-messenger.png)
11
12
13 ## Installation
14
15 `git-messenger` is available on [MELPA](https://melpa.org/) and [MELPA stable](https://stable.melpa.org/)
16
17 You can install `git-messenger` with the following command.
18
19 <kbd>M-x package-install [RET] git-messenger [RET]</kbd>
20
21
22 ## Dependency
23
24 * [popup](https://github.com/auto-complete/popup-el)
25
26
27 ## Supported VCS
28
29 - Git
30 - Subversion
31 - Mercurial
32
33
34 ## Commands
35
36 ### `git-messenger:popup-message`
37
38 Pop up last commit message at current line. Show detail message, Commit ID, Author,
39 Date and commit message with `C-u` prefix
40
41 ![Screenshot of git-messenger with prefix argument](image/git-messenger-detail.png)
42
43
44 ## Key Bindings
45
46 You can modify key bindings by customizing `git-messenger-map`.
47
48 | Key | Command |
49 |:--------------------:|:--------------------------------------------------------|
50 | `M-w` | Copy commit message and quit |
51 | `c` | Copy commit ID and quit |
52 | `d` | Pop up `git diff` of last change of this line |
53 | `s` | Pop up `git show --stat` of last change of this line |
54 | `S` | Pop up `git show --stat -p` of last change of this line |
55 | `q` | Quit |
56
57
58 ## Customize
59
60 ### `git-messenger:show-detail`(Default `nil`)
61
62 Always show detail message if this value is `t`.
63
64 ### `git-messenger:handled-backends`(Default `'(git svn)`)
65
66 Handled VCS which `git-messenger` uses.
67 Entries in this list will be tried in order to determine whether a
68 file is under that sort of version control.
69
70 ### `git-messenger:use-magit-popup`(Default `nil`)
71
72 Use `magit-show-commit` instead of `pop-to-buffer`.
73
74 ## Hooks
75
76 ### `git-messenger:before-popup-hook`
77
78 Run before popup commit message. Hook function take one argument, commit message.
79
80 ### `git-messenger:after-popup-hook`
81
82 Run after popup commit message. Hook function take one argument, commit message.
83
84 ### `git-messenger:popup-buffer-hook`
85
86 Run after popup buffer.
87
88
89 ## Global Variables
90
91 You may be able to use these variables useful in commands of `git-messenger-map`.
92
93 #### `git-messenger:last-message`
94
95 Last popup-ed commit message
96
97 #### `git-messenger:last-commit-id`
98
99 Last popup-ed commit ID
100
101
102 ## Sample Configuration
103
104 ```lisp
105 (require 'git-messenger) ;; You need not to load if you install with package.el
106 (global-set-key (kbd "C-x v p") 'git-messenger:popup-message)
107
108 (define-key git-messenger-map (kbd "m") 'git-messenger:copy-message)
109
110 ;; Enable magit-show-commit instead of pop-to-buffer
111 (custom-set-variables
112 '(git-messenger:use-magit-popup t))
113 ```
114
115 [melpa-link]: https://melpa.org/#/git-messenger
116 [melpa-stable-link]: https://stable.melpa.org/#/git-messenger
117 [melpa-badge]: https://melpa.org/packages/git-messenger-badge.svg
118 [melpa-stable-badge]: https://stable.melpa.org/packages/git-messenger-badge.svg
0 ;;; git-messenger.el --- Pop up last commit information of current line -*- lexical-binding: t -*-
1
2 ;; Copyright (C) 2017 by Syohei YOSHIDA
3
4 ;; Author: Syohei YOSHIDA <syohex@gmail.com>
5 ;; URL: https://github.com/syohex/emacs-git-messenger
6 ;; Version: 0.18
7 ;; Package-Requires: ((emacs "24.3") (popup "0.5.0"))
8
9 ;; This program is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; This program is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23
24 ;; This package provides a function called git-messenger:popup-message
25 ;; that when called will pop-up the last git commit message for the
26 ;; current line. This uses the git-blame tool internally.
27 ;;
28 ;; Example usage:
29 ;; (require 'git-messenger)
30 ;; (global-set-key (kbd "C-x v p") 'git-messenger:popup-message)
31 ;;
32
33 ;;; Code:
34
35 (require 'cl-lib)
36 (require 'popup)
37
38 (declare-function magit-show-commit "magit-diff")
39
40 (defgroup git-messenger nil
41 "git messenger"
42 :group 'vc)
43
44 (defcustom git-messenger:show-detail nil
45 "Pop up commit ID and author name too"
46 :type 'boolean)
47
48 (defcustom git-messenger:before-popup-hook nil
49 "Hook run before popup commit message. This hook is taken popup-ed message"
50 :type 'hook)
51
52 (defcustom git-messenger:after-popup-hook nil
53 "Hook run after popup commit message. This hook is taken popup-ed message"
54 :type 'hook)
55
56 (defcustom git-messenger:popup-buffer-hook nil
57 "Hook run after popup buffer(popup diff, popup show etc)"
58 :type 'hook)
59
60 (defcustom git-messenger:handled-backends '(git svn hg)
61 "List of version control backends for which `git-messenger' will be used.
62 Entries in this list will be tried in order to determine whether a
63 file is under that sort of version control."
64 :type '(repeat symbol))
65
66 (defcustom git-messenger:use-magit-popup nil
67 "Use magit-show-commit instead pop-to-buffer"
68 :type 'boolean)
69
70 (defvar git-messenger:last-message nil
71 "Last message displayed by git-messenger.
72
73 This is set before the pop-up is displayed so accessible in the hooks
74 and menus.")
75
76 (defvar git-messenger:last-commit-id nil
77 "Last commit id for the last message displayed.
78
79 This is set before the pop-up is displayed so accessible in the hooks
80 and menus.")
81
82 (defvar git-messenger:vcs nil)
83
84 (defconst git-messenger:directory-of-vcs
85 '((git . ".git")
86 (svn . ".svn")
87 (hg . ".hg")))
88
89 (defun git-messenger:blame-arguments (vcs file line)
90 (let ((basename (file-name-nondirectory file)))
91 (cl-case vcs
92 (git (list "--no-pager" "blame" "-w" "-L"
93 (format "%d,+1" line)
94 "--porcelain" basename))
95 (svn (list "blame" basename))
96 (hg (list "blame" "-wuc" basename)))))
97
98 (defsubst git-messenger:cat-file-arguments (commit-id)
99 (list "--no-pager" "cat-file" "commit" commit-id))
100
101 (defsubst git-messenger:vcs-command (vcs)
102 (cl-case vcs
103 (git "git")
104 (svn "svn")
105 (hg "hg")))
106
107 (defun git-messenger:execute-command (vcs args output)
108 (cl-case vcs
109 (git (apply 'process-file "git" nil output nil args))
110 (svn
111 (let ((process-environment (cons "LANG=C" process-environment)))
112 (apply 'process-file "svn" nil output nil args)))
113 (hg
114 (let ((process-environment (cons
115 "HGPLAIN=1"
116 (cons "LANG=utf-8" process-environment))))
117 (apply 'process-file "hg" nil output nil args)))))
118
119 (defun git-messenger:git-commit-info-at-line ()
120 (let* ((id-line (buffer-substring-no-properties
121 (line-beginning-position) (line-end-position)))
122 (commit-id (car (split-string id-line)))
123 (author (if (re-search-forward "^author \\(.+\\)$" nil t)
124 (match-string-no-properties 1)
125 "unknown")))
126 (cons commit-id author)))
127
128 (defun git-messenger:hg-commit-info-at-line (line)
129 (forward-line (1- line))
130 (if (looking-at "^\\s-*\\(\\S-+\\)\\s-+\\([a-z0-9]+\\)")
131 (cons (match-string-no-properties 2) (match-string-no-properties 1))
132 (cons "-" "-")))
133
134 (defun git-messenger:svn-commit-info-at-line (line)
135 (forward-line (1- line))
136 (if (looking-at "^\\s-*\\([0-9]+\\)\\s-+\\(\\S-+\\)")
137 (cons (match-string-no-properties 1) (match-string-no-properties 2))
138 (cons "-" "-")))
139
140 (defun git-messenger:commit-info-at-line (vcs file line)
141 (with-temp-buffer
142 (let ((args (git-messenger:blame-arguments vcs file line)))
143 (unless (zerop (git-messenger:execute-command vcs args t))
144 (error "Failed: '%s blame'" (git-messenger:vcs-command vcs)))
145 (goto-char (point-min))
146 (cl-case vcs
147 (git (git-messenger:git-commit-info-at-line))
148 (svn (git-messenger:svn-commit-info-at-line line))
149 (hg (git-messenger:hg-commit-info-at-line line))))))
150
151 (defsubst git-messenger:not-committed-id-p (commit-id)
152 (or (string-match-p "\\`\\(?:0+\\|-\\)\\'" commit-id)))
153
154 (defun git-messenger:git-commit-message (commit-id)
155 (let ((args (git-messenger:cat-file-arguments commit-id)))
156 (unless (zerop (git-messenger:execute-command 'git args t))
157 (error "Failed: 'git cat-file'"))
158 (goto-char (point-min))
159 (forward-paragraph)
160 (buffer-substring-no-properties (point) (point-max))))
161
162 (defun git-messenger:hg-commit-message (commit-id)
163 (let ((args (list "log" "-T" "{desc}" "-r" commit-id)))
164 (unless (zerop (git-messenger:execute-command 'hg args t))
165 (error "Failed: 'hg log"))
166 (buffer-substring-no-properties (point-min) (point-max))))
167
168 (defun git-messenger:svn-commit-message (commit-id)
169 (let ((args (list "log" "-c" commit-id)))
170 (unless (zerop (git-messenger:execute-command 'svn args t))
171 (error "Failed: 'svn log"))
172 (let (end)
173 (goto-char (point-max))
174 (when (re-search-backward "^-\\{25\\}" nil t)
175 (setq end (point)))
176 (buffer-substring-no-properties (point-min) (or end (point-max))))))
177
178 (defun git-messenger:commit-message (vcs commit-id)
179 (with-temp-buffer
180 (if (git-messenger:not-committed-id-p commit-id)
181 "* not yet committed *"
182 (cl-case vcs
183 (git (git-messenger:git-commit-message commit-id))
184 (svn (git-messenger:svn-commit-message commit-id))
185 (hg (git-messenger:hg-commit-message commit-id))))))
186
187 (defun git-messenger:commit-date (commit-id)
188 (let ((args (list "--no-pager" "show" "--pretty=%cd" commit-id)))
189 (with-temp-buffer
190 (unless (zerop (git-messenger:execute-command 'git args t))
191 (error "Failed 'git show'"))
192 (goto-char (point-min))
193 (buffer-substring-no-properties
194 (line-beginning-position) (line-end-position)))))
195
196 (defun git-messenger:hg-commit-date (commit-id)
197 (let ((args (list "log" "-T" "{date|rfc822date}" "-r" commit-id)))
198 (with-temp-buffer
199 (unless (zerop (git-messenger:execute-command 'hg args t))
200 (error "Failed 'hg log'"))
201 (goto-char (point-min))
202 (buffer-substring-no-properties
203 (line-beginning-position) (line-end-position)))))
204
205 (defun git-messenger:format-detail (vcs commit-id author message)
206 (cl-case vcs
207 (git (let ((date (git-messenger:commit-date commit-id)))
208 (format "commit : %s \nAuthor : %s\nDate : %s \n%s"
209 (substring commit-id 0 8) author date message)))
210 (hg (let ((date (git-messenger:hg-commit-date commit-id)))
211 (format "commit : %s \nAuthor : %s\nDate : %s \n%s"
212 commit-id author date message)))
213 (svn (with-temp-buffer
214 (insert message)
215 (goto-char (point-min))
216 (forward-line 1)
217 (let ((line (buffer-substring-no-properties (point) (line-end-position)))
218 (re "^\\s-*\\(?:r[0-9]+\\)\\s-+|\\s-+\\([^|]+\\)|\\s-+\\([^|]+\\)"))
219 (unless (string-match re line)
220 (error "Can't get revision %s" line))
221 (let ((author (match-string-no-properties 1 line))
222 (date (match-string-no-properties 2 line)))
223 (forward-paragraph)
224 (format "commit : r%s \nAuthor : %s\nDate : %s\n%s"
225 commit-id author date
226 (buffer-substring-no-properties (point) (point-max)))))))))
227
228 (defun git-messenger:show-detail-p (commit-id)
229 (and (or git-messenger:show-detail current-prefix-arg)
230 (not (git-messenger:not-committed-id-p commit-id))))
231
232 (defun git-messenger:popup-close ()
233 (interactive)
234 (throw 'git-messenger-loop t))
235
236 (defun git-messenger:copy-message ()
237 "Copy current displayed commit message to kill-ring."
238 (interactive)
239 (when git-messenger:last-message
240 (kill-new git-messenger:last-message))
241 (git-messenger:popup-close))
242
243 (defun git-messenger:copy-commit-id ()
244 "Copy current displayed commit id to kill-ring."
245 (interactive)
246 (when git-messenger:last-commit-id
247 (kill-new git-messenger:last-commit-id))
248 (git-messenger:popup-close))
249
250 (defun git-messenger:popup-common (vcs args &optional mode)
251 (with-current-buffer (get-buffer-create "*git-messenger*")
252 (view-mode -1)
253 (fundamental-mode)
254 (erase-buffer)
255 (unless (zerop (git-messenger:execute-command vcs args t))
256 (error "Failed: '%s(args=%s)'" (git-messenger:vcs-command vcs) args))
257 (if git-messenger:use-magit-popup
258 (magit-show-commit git-messenger:last-commit-id)
259 (pop-to-buffer (current-buffer))
260 (when mode
261 (funcall mode)))
262 (run-hooks 'git-messenger:popup-buffer-hook)
263 (view-mode +1)
264 (goto-char (point-min)))
265 (git-messenger:popup-close))
266
267 (defun git-messenger:popup-svn-show ()
268 (git-messenger:popup-common
269 'svn (list "diff" "-c" git-messenger:last-commit-id) 'diff-mode))
270
271 (defun git-messenger:popup-hg-show ()
272 (git-messenger:popup-common
273 'hg (list "diff" "-c" git-messenger:last-commit-id) 'diff-mode))
274
275 (defun git-messenger:popup-diff ()
276 (interactive)
277 (cl-case git-messenger:vcs
278 (git (let ((args (list "--no-pager" "diff" "--no-ext-diff"
279 (concat git-messenger:last-commit-id "^!"))))
280 (git-messenger:popup-common 'git args 'diff-mode)))
281 (svn (git-messenger:popup-svn-show))
282 (hg (git-messenger:popup-hg-show))))
283
284 (defun git-messenger:popup-show ()
285 (interactive)
286 (cl-case git-messenger:vcs
287 (git (let ((args (list "--no-pager" "show" "--no-ext-diff" "--stat"
288 git-messenger:last-commit-id)))
289 (git-messenger:popup-common 'git args)))
290 (svn (git-messenger:popup-svn-show))
291 (hg (let ((args (list "log" "--stat" "-r"
292 git-messenger:last-commit-id)))
293 (git-messenger:popup-common 'hg args)))))
294
295 (defun git-messenger:popup-show-verbose ()
296 (interactive)
297 (cl-case git-messenger:vcs
298 (git (let ((args (list "--no-pager" "show" "--no-ext-diff" "--stat" "-p"
299 git-messenger:last-commit-id)))
300 (git-messenger:popup-common 'git args)))
301 (svn (error "'svn' does not support `popup-show-verbose'"))
302 (hg (let ((args (list "log" "-p" "--stat" "-r"
303 git-messenger:last-commit-id)))
304 (git-messenger:popup-common 'hg args)))))
305
306 (defvar git-messenger-map
307 (let ((map (make-sparse-keymap)))
308 ;; key bindings
309 (define-key map (kbd "q") 'git-messenger:popup-close)
310 (define-key map (kbd "c") 'git-messenger:copy-commit-id)
311 (define-key map (kbd "d") 'git-messenger:popup-diff)
312 (define-key map (kbd "s") 'git-messenger:popup-show)
313 (define-key map (kbd "S") 'git-messenger:popup-show-verbose)
314 (define-key map (kbd "M-w") 'git-messenger:copy-message)
315 (define-key map (kbd ",") 'git-messenger:show-parent)
316 map)
317 "Key mappings of git-messenger. This is enabled when commit message is popup-ed.")
318
319 (defun git-messenger:find-vcs ()
320 (let ((longest 0)
321 result)
322 (dolist (vcs git-messenger:handled-backends result)
323 (let* ((dir (assoc-default vcs git-messenger:directory-of-vcs))
324 (vcs-root (locate-dominating-file default-directory dir)))
325 (when (and vcs-root (> (length vcs-root) longest))
326 (setq longest (length vcs-root)
327 result vcs))))))
328
329 (defun git-messenger:svn-message (msg)
330 (with-temp-buffer
331 (insert msg)
332 (goto-char (point-min))
333 (forward-paragraph)
334 (buffer-substring-no-properties (point) (point-max))))
335
336 (defvar git-messenger:func-prompt
337 '((git-messenger:popup-show . "Show")
338 (git-messenger:popup-show-verbose . "Show verbose")
339 (git-messenger:popup-close . "Close")
340 (git-messenger:copy-commit-id . "Copy hash")
341 (git-messenger:popup-diff . "Diff")
342 (git-messenger:copy-message . "Copy message")
343 (git-messenger:show-parent . "Go Parent")
344 (git-messenger:popup-close . "Quit")))
345
346 (defsubst git-messenger:function-to-key (func)
347 (key-description (car-safe (where-is-internal func git-messenger-map))))
348
349 (defun git-messenger:prompt ()
350 (mapconcat (lambda (fp)
351 (let ((key (git-messenger:function-to-key (car fp))))
352 (format "[%s]%s" key (cdr fp))))
353 git-messenger:func-prompt " "))
354
355 (defun git-messenger:show-parent ()
356 (interactive)
357 (let ((file (buffer-file-name (buffer-base-buffer))))
358 (cl-case git-messenger:vcs
359 (git (with-temp-buffer
360 (unless (zerop (process-file "git" nil t nil
361 "blame" "--increment" git-messenger:last-commit-id "--" file))
362 (error "No parent commit ID"))
363 (goto-char (point-min))
364 (when (re-search-forward (concat "^" git-messenger:last-commit-id) nil t)
365 (when (re-search-forward "previous \\(\\S-+\\)" nil t)
366 (let ((parent (match-string-no-properties 1)))
367 (setq git-messenger:last-commit-id parent
368 git-messenger:last-message (git-messenger:commit-message 'git parent)))))
369 (throw 'git-messenger-loop nil)))
370 (otherwise (error "%s does not support for getting parent commit ID" git-messenger:vcs)))))
371
372 ;;;###autoload
373 (defun git-messenger:popup-message ()
374 (interactive)
375 (let* ((vcs (git-messenger:find-vcs))
376 (file (buffer-file-name (buffer-base-buffer)))
377 (line (line-number-at-pos))
378 (commit-info (git-messenger:commit-info-at-line vcs file line))
379 (commit-id (car commit-info))
380 (author (cdr commit-info))
381 (msg (git-messenger:commit-message vcs commit-id))
382 (popuped-message (if (git-messenger:show-detail-p commit-id)
383 (git-messenger:format-detail vcs commit-id author msg)
384 (cl-case vcs
385 (git msg)
386 (svn (if (string= commit-id "-")
387 msg
388 (git-messenger:svn-message msg)))
389 (hg msg)))))
390 (setq git-messenger:vcs vcs
391 git-messenger:last-message popuped-message
392 git-messenger:last-commit-id commit-id)
393 (let (finish)
394 (run-hook-with-args 'git-messenger:before-popup-hook popuped-message)
395 (while (not finish)
396 (let ((menu (popup-tip git-messenger:last-message :nowait t)))
397 (unwind-protect
398 (setq finish (catch 'git-messenger-loop
399 (popup-menu-event-loop menu git-messenger-map 'popup-menu-fallback
400 :prompt (git-messenger:prompt))
401 t))
402 (popup-delete menu)))))
403 (run-hook-with-args 'git-messenger:after-popup-hook popuped-message)))
404
405 (provide 'git-messenger)
406
407 ;; Local Variables:
408 ;; coding: utf-8
409 ;; indent-tabs-mode: nil
410 ;; End:
411
412 ;;; git-messenger.el ends here
Binary diff not shown
0 ;;; test.el --- test of git-messenger
1
2 ;; Copyright (C) 2016 by Syohei YOSHIDA
3
4 ;; Author: Syohei YOSHIDA <syohex@gmail.com>
5
6 ;; This program is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation, either version 3 of the License, or
9 ;; (at your option) any later version.
10
11 ;; This program is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;; GNU General Public License for more details.
15
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ;;; Code:
20
21 (require 'ert)
22 (require 'git-messenger)
23
24 (ert-deftest find-vcs ()
25 ""
26 (let* ((tmp-dir (file-name-as-directory
27 (concat default-directory (make-temp-name "git-messenger"))))
28 (git-dir (concat tmp-dir ".git"))
29 (hg-dir (concat tmp-dir "foo/" ".hg"))
30 (test-dir (concat tmp-dir "foo/bar/")))
31 (unwind-protect
32 (progn
33 (make-directory git-dir t)
34 (make-directory hg-dir t)
35 (make-directory test-dir t)
36 (let ((default-directory test-dir))
37 (should (eq (git-messenger:find-vcs) 'hg))))
38 (delete-directory tmp-dir t))))
39
40 ;;; test.el ends here