mirror of
https://codeberg.org/gwh/slackbuilds.git
synced 2024-11-16 19:51:19 +01:00
(changes)
This commit is contained in:
parent
507abe1a96
commit
bdc23da0f3
2 changed files with 53 additions and 20 deletions
1
.#git-status.el
Symbolic link
1
.#git-status.el
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
mvo@manamana.16547:1212169673
|
|
@ -46,6 +46,17 @@
|
||||||
(substring str 0 (- (length str) 1))
|
(substring str 0 (- (length str) 1))
|
||||||
str))))
|
str))))
|
||||||
|
|
||||||
|
(defun gits-concat-with-delim (delim seqs)
|
||||||
|
(cond ((null seqs)
|
||||||
|
nil)
|
||||||
|
((null (cdr seqs))
|
||||||
|
(car seqs))
|
||||||
|
(t
|
||||||
|
(concat (car seqs) delim (gits-concat-with-delim delim (cdr seqs))))))
|
||||||
|
|
||||||
|
(defun gits-get (&rest keys)
|
||||||
|
(gits-shell "git-config %s" (gits-concat-with-delim "." keys)))
|
||||||
|
|
||||||
(defun gits-get-top-dir (cwd)
|
(defun gits-get-top-dir (cwd)
|
||||||
(let* ((cwd (expand-file-name cwd))
|
(let* ((cwd (expand-file-name cwd))
|
||||||
(git-dir (gits-shell "cd '%s' && git-rev-parse --git-dir 2>/dev/null"
|
(git-dir (gits-shell "cd '%s' && git-rev-parse --git-dir 2>/dev/null"
|
||||||
|
@ -54,8 +65,21 @@
|
||||||
(file-name-as-directory (or (file-name-directory git-dir) cwd))
|
(file-name-as-directory (or (file-name-directory git-dir) cwd))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(defun gits-get (key)
|
(defun gits-get-ref (ref)
|
||||||
(gits-shell "git-config %s" key))
|
(gits-shell "git-symbolic-ref -q %s" ref))
|
||||||
|
|
||||||
|
(defun gits-get-current-branch ()
|
||||||
|
(let* ((head (gits-get-ref "HEAD"))
|
||||||
|
(pos (and head (string-match "^refs/heads/" head))))
|
||||||
|
(if pos
|
||||||
|
(substring head 11)
|
||||||
|
nil)))
|
||||||
|
|
||||||
|
(defun gits-read-top-dir (prefix)
|
||||||
|
(let ((dir (gits-get-top-dir default-directory)))
|
||||||
|
(if prefix
|
||||||
|
(gits-get-top-dir (read-directory-name "Git repository: " dir))
|
||||||
|
dir)))
|
||||||
|
|
||||||
;;; Running asynchronous commands
|
;;; Running asynchronous commands
|
||||||
|
|
||||||
|
@ -96,11 +120,20 @@
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
(insert (format "Repository: %s\n"
|
(insert (format "Repository: %s\n"
|
||||||
(abbreviate-file-name default-directory)))
|
(abbreviate-file-name default-directory)))
|
||||||
|
(let ((branch (gits-get-current-branch)))
|
||||||
(insert (format "Branch: %s\n"
|
(insert (format "Branch: %s\n"
|
||||||
(gits-shell "git-symbolic-ref -q HEAD")))
|
(or branch "(detached)")))
|
||||||
(let ((origin (gits-get "remote.origin.url")))
|
(if branch
|
||||||
(if origin
|
(let ((remote (gits-get "branch" branch "remote")))
|
||||||
(insert (format "Origin: %s\n" origin))))
|
(if remote
|
||||||
|
(let* ((push (gits-get "remote" remote "push"))
|
||||||
|
(pull (gits-get "remote" remote "fetch"))
|
||||||
|
(desc (if (equal push pull)
|
||||||
|
push
|
||||||
|
(format "%s -> %s" pull push))))
|
||||||
|
(insert (format "Remote: %s\n %s\n"
|
||||||
|
desc
|
||||||
|
(gits-get "remote" remote "url"))))))))
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
(insert "Local changes:\n")
|
(insert "Local changes:\n")
|
||||||
(call-process-shell-command "git diff" nil t)
|
(call-process-shell-command "git diff" nil t)
|
||||||
|
@ -110,27 +143,26 @@
|
||||||
|
|
||||||
;;; Main
|
;;; Main
|
||||||
|
|
||||||
(defun git-status (cwd)
|
(defun git-status (dir)
|
||||||
(interactive "DDirectory: ")
|
(interactive (list (gits-read-top-dir current-prefix-arg)))
|
||||||
(let ((dir (gits-get-top-dir cwd)))
|
|
||||||
(or dir
|
|
||||||
(error "Not a git repository."))
|
|
||||||
(let ((buf (get-buffer-create "*git-status*")))
|
(let ((buf (get-buffer-create "*git-status*")))
|
||||||
(switch-to-buffer buf)
|
(switch-to-buffer buf)
|
||||||
(setq default-directory dir)
|
(setq default-directory dir)
|
||||||
(gits-update-status))))
|
(gits-update-status)))
|
||||||
|
|
||||||
(defun git-status-here ()
|
(defun git-show-status ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(git-status default-directory))
|
(let ((buf (get-buffer-create "*git-status*")))
|
||||||
|
(switch-to-buffer buf)
|
||||||
|
(gits-update-status)))
|
||||||
|
|
||||||
(defun git-pull ()
|
(defun git-pull ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(gits-run "git-pull" "origin" "master"))
|
(gits-run "git-pull"))
|
||||||
|
|
||||||
(defun git-push ()
|
(defun git-push ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(gits-run "git-push" "origin"))
|
(gits-run "git-push"))
|
||||||
|
|
||||||
(defun git-stage-all ()
|
(defun git-stage-all ()
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
Loading…
Reference in a new issue