[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gited c8eaa05 58/73: gited.el: Merge branch 'show-trunk
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gited c8eaa05 58/73: gited.el: Merge branch 'show-trunk-ci-status' |
Date: |
Sun, 29 Nov 2020 00:00:39 -0500 (EST) |
branch: externals/gited
commit c8eaa0562f1d0397c464ba8508bbf965fe5669c8
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>
gited.el: Merge branch 'show-trunk-ci-status'
---
gited.el | 51 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 13 deletions(-)
diff --git a/gited.el b/gited.el
index b1c9958..82e03ad 100644
--- a/gited.el
+++ b/gited.el
@@ -244,6 +244,7 @@
;;; Code:
+(require 'gited-ci)
(require 'cl-lib)
(require 'tabulated-list)
(require 'dired)
@@ -665,6 +666,8 @@ The value returned is the value of the last form in BODY."
(declare (indent 1) (debug t))
(let ((cur-branch (make-symbol "cur-branch")))
`(let ((,cur-branch gited-current-branch))
+ (when (gited-modified-files-p)
+ (user-error "Cannot checkout a new branch: there are modified files"))
(unwind-protect
(progn
(gited-git-checkout nil ,branch)
@@ -1094,32 +1097,43 @@ DATA is a string to specify what we want to extract.
For instance:
(gited-git-command args (current-buffer) nil 'unquote)
(buffer-string))))
-(defun gited--last-commit-msg ()
+(defun gited--last-commit-msg (&optional branch)
"Return the last commit."
- (gited--extract-from-commit "HEAD" "%B"))
+ (gited--extract-from-commit (or branch "HEAD") "%B"))
-(defun gited--last-commit-title ()
+(defun gited--last-commit-title (&optional branch)
"Return title of the last commit."
- (gited--extract-from-commit "HEAD" "%s"))
+ (gited--extract-from-commit (or branch "HEAD") "%s"))
-(defun gited--last-commit-author ()
+(defun gited--last-commit-author (&optional branch)
"Return the last commit."
- (gited--extract-from-commit "HEAD" "%an <%ae>"))
+ (gited--extract-from-commit (or branch "HEAD") "%an <%ae>"))
-(defun gited--last-commit-date ()
+(defun gited--last-commit-date (&optional branch)
"Return the last commit."
- (gited--extract-from-commit "HEAD" "%ai"))
+ (gited--extract-from-commit (or branch "HEAD") "%ai"))
+
+(defun gited--last-commit-hash (&optional branch)
+ "Return the last commit hash string."
+ (gited--extract-from-commit (or branch "HEAD") "%H"))
+
+(defun gited--last-trunk-commit ()
+ (gited--last-commit-hash (gited-trunk-branch)))
;; Non-nil while running an asynchronous Gited subprocess.
(defvar-local gited--running-async-op nil)
-(defun gited-async-operation (command &optional remote-op-p buffer)
+(defvar gited-async-operation-callback nil
+ "A function to call once the current async process sucessfully completes.")
+
+(defun gited-async-operation (command &optional remote-op-p buffer callback)
"Run COMMAND asynchronously.
COMMAND perform a branch operation, i.e., rename or delete a branch.
Optional arg REMOTE-OP-P, means the operation modify the remote
repository. Otherwise, the operation just change local branches.
Optional arg BUFFER is the output buffer for the operation. Otherwise,
-use `gited-output-buffer'."
+use `gited-output-buffer'.
+Optional arg CALLBACK is called if COMMAND completes successfully."
(interactive)
(if gited--running-async-op
(user-error "Cannot run 2 Gited async process in parallel")
@@ -1140,6 +1154,7 @@ use `gited-output-buffer'."
(setq gited--running-async-op t))
(with-no-warnings
(require 'shell) (shell-mode))
+ (setq gited-async-operation-callback callback)
(set-process-sentinel proc 'gited-async-operation-sentinel)
(set-process-filter proc 'comint-output-filter)
;; Associate out-buf with gited-buf; this is used in the sentinel.
@@ -1168,7 +1183,12 @@ STATE is the state of process PROC."
gited-op-string nil))
;; State is 'finished\n' when the process exit with code 0.
(if (string-prefix-p "finished" state)
- (message "%s done!" op-string)
+ (progn
+ (message "%s done!" op-string)
+ (when gited-async-operation-callback
+ (prog1
+ (funcall gited-async-operation-callback)
+ (setq gited-async-operation-callback nil))))
(beep)
(message "Process exited with non-zero status. Please check")
(display-buffer gited-output-buffer)))))
@@ -2077,6 +2097,7 @@ show similar info as that command."
gited-current-remote-rep))))
(message "OK, pull canceled")
(let ((buf (gited--output-buffer))
+ (last-trunk-commit (gited--last-trunk-commit))
(cmd (format "%s pull %s"
vc-git-program
gited-current-remote-rep))
@@ -2084,7 +2105,8 @@ show similar info as that command."
(setq gited-output-buffer buf
gited-op-string cmd)
(with-current-buffer buf (erase-buffer))
- (gited-async-operation cmd 'remote-op-p))))
+ (setq gited-last-trunk-commit last-trunk-commit)
+ (gited-async-operation cmd 'remote-op-p nil #'gited-pull-callback))))
(defun gited-push (&optional force-with-lease)
"Run git push in current branch.
@@ -3596,7 +3618,10 @@ When called interactively with a prefix set OTHER-WINDOW
non-nil."
(gited-fontify-current-branch))
(unless gited--hide-details-set
(or gited-verbose (gited-hide-details-mode 1))
- (setq gited--hide-details-set t)))))
+ (setq gited--hide-details-set t))
+ ;; For local branches, show the CI status of the trunk branch.
+ (when (string= pattern "local") (gited-pull-callback)))))
+
;;;###autoload
(defalias 'gited-list 'gited-list-branches)
- [elpa] externals/gited f81463e 44/73: gited-git-checkout: New function, (continued)
- [elpa] externals/gited f81463e 44/73: gited-git-checkout: New function, Stefan Monnier, 2020/11/29
- [elpa] externals/gited d78161b 56/73: * packages/gited/gited.el (gited-pull): Delete unused variable, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 475e297 72/73: Support Gited buffers over a tramp connection, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 8f6722e 66/73: * gited.el: Bump version to 0.5.4, Stefan Monnier, 2020/11/29
- [elpa] externals/gited e8f116d 02/73: Default to beginning of epoch when no commit time info, Stefan Monnier, 2020/11/29
- [elpa] externals/gited cc4d5f7 17/73: Use taggerdate/taggername when listing tags, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 68c723a 46/73: * gited.el (gited-git-checkout): Avoid harmless warning., Stefan Monnier, 2020/11/29
- [elpa] externals/gited 7a691c9 57/73: Skip tests when Git is not available, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 33c42d9 55/73: gited-pull fetches all remote branches, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 96ec28a 35/73: * gited.el (gited-goto-branch): Return point on success., Stefan Monnier, 2020/11/29
- [elpa] externals/gited c8eaa05 58/73: gited.el: Merge branch 'show-trunk-ci-status',
Stefan Monnier <=
- [elpa] externals/gited 736ac62 52/73: Do not assume that 'git rev-parse 1' exits with status != 0, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 910cf66 40/73: * gited.el (gited-do-sync-with-trunk): Fix typo in docstring., Stefan Monnier, 2020/11/29
- [elpa] externals/gited dc0b527 38/73: gited-do-sync-with-trunk: New command, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 2ce2163 13/73: Prune deleted remote branches, Stefan Monnier, 2020/11/29
- [elpa] externals/gited fac8958 03/73: gited-list-branches: Move to current branch only when it's shown, Stefan Monnier, 2020/11/29
- [elpa] externals/gited aba4cf9 18/73: * gited.el (gited-goto-branch): Check first that BRANCH is shown., Stefan Monnier, 2020/11/29
- [elpa] externals/gited b0fe243 19/73: * gited.el (gited-set-branch-upstream): Output buffer must be editable., Stefan Monnier, 2020/11/29
- [elpa] externals/gited ff44a0d 23/73: * gited.el (gited-tag-add): Fix docstring., Stefan Monnier, 2020/11/29
- [elpa] externals/gited b4e58ca 27/73: gited-list: Add autoload cookie, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 7ed4084 24/73: * gited.el (gited-list-branches): Update docstring. Make alias to `gited-list'., Stefan Monnier, 2020/11/29