[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/gited dc0b527 38/73: gited-do-sync-with-trunk: New comm
From: |
Stefan Monnier |
Subject: |
[elpa] externals/gited dc0b527 38/73: gited-do-sync-with-trunk: New command |
Date: |
Sun, 29 Nov 2020 00:00:35 -0500 (EST) |
branch: externals/gited
commit dc0b527354ebf892496e5e2132c285844117400f
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>
gited-do-sync-with-trunk: New command
* gited.el (gited-do-sync-with-trunk): New command. Bind it to 'T'.
(gited--sync-with-trunk-target-name): New defun extracted from
`gited-sync-with-trunk'.
(gited--sync-with-trunk-target-name): Use it.
(gited-sync-with-trunk): Idem. Signal error if BRANCH-TARGET already exits.
Update docstring.
---
gited.el | 40 ++++++++++++++++++++++++++++++----------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/gited.el b/gited.el
index 01c7a96..8f0bcf4 100644
--- a/gited.el
+++ b/gited.el
@@ -10,9 +10,9 @@
;; Compatibility: GNU Emacs: 24.4
;; Version: 0.2.5
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
-;; Last-Updated: Sat Jul 01 13:19:13 JST 2017
+;; Last-Updated: Sat Jul 01 13:24:22 JST 2017
;; By: calancha
-;; Update #: 669
+;; Update #: 670
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -2135,21 +2135,26 @@ Optional arg WRITE-FILE if non-nil, then write the
patches to disk."
(string< (buffer-name x) (buffer-name y)))
)))
+(defun gited--sync-with-trunk-target-name (&optional branch)
+ (unless branch (setq branch (gited-get-branchname)))
+ (if (string-match "-new\\([0-9]*\\)\\'" branch)
+ (format "%s%d" (substring branch 0 (match-beginning 1))
+ (1+ (string-to-number (match-string 1 branch))))
+ (concat branch "-new1")))
+
(defun gited-sync-with-trunk (branch-target)
"Extract latest patches in branch at point and apply then into BRANCH-TARGET.
BRANCH-TARGET is a new branch copied from (car (gited-trunk-branches)).
+
The effect is similar than merge the branch at point with the trunk;
one difference is that we don't modify the trunk, instead we copy it;
-another difference that we don't get a 'Merge branch...' commit in the log.
-this command set BRANCH-TARGET current."
+another difference is that we don't get a 'Merge branch...' commit in the log.
+This command sets BRANCH-TARGET current."
(interactive
(let* ((br (gited-get-branchname))
(prompt
(format "Syncronized '%s' into new branch: " br))
- (def (if (string-match "-new\\([0-9]*\\)\\'" br)
- (format "%s%d" (substring br 0 (match-beginning 1))
- (1+ (string-to-number (match-string 1 br))))
- (concat br "-new1"))))
+ (def (gited--sync-with-trunk-target-name br)))
(list
(completing-read prompt
(gited-listed-branches)
@@ -2159,6 +2164,8 @@ this command set BRANCH-TARGET current."
(unless (gited-remote-repository-p)
(user-error "This command only works for repositories \
tracking a remote repository"))
+ (when (gited-branch-exists-p branch-target)
+ (user-error "Branch '%s' already exists" branch-target))
(if (null (ignore-errors (gited-extract-patches nil t)))
(user-error "No new patches to apply")
;; If branch-target doesn't exists create it as copy of master.
@@ -2179,10 +2186,23 @@ tracking a remote repository"))
(setq buf-patches (cdr buf-patches)
buf-commits (cdr buf-commits)))))
(gited-checkout-branch branch-target)
- (gited-update)
(message "Successfully applied and committed %d commits!"
num-commits))))
+(defun gited-do-sync-with-trunk (&optional dont-ask)
+ (interactive "P")
+ (dolist (br (or (gited-get-marked-branches) (list (gited-get-branchname))))
+ (let* ((prompt
+ (format "Syncronized '%s' into new branch: " br))
+ (def (gited--sync-with-trunk-target-name br))
+ (target
+ (if dont-ask def
+ (completing-read
+ prompt (gited-listed-branches)
+ nil nil def))))
+ (gited-sync-with-trunk target)))
+ (gited-update))
+
(defun gited-bisecting-p ()
"Return non-nil if a Git bisect is on process."
(zerop (gited-git-command '("bisect" "log"))))
@@ -3298,7 +3318,7 @@ in the active region."
(define-key map (kbd "C-c c") 'gited-commit)
(define-key map (kbd "w") 'gited-copy-branchname-as-kill)
(define-key map (kbd "e") 'gited-extract-patches)
- (define-key map (kbd "T") 'gited-sync-with-trunk)
+ (define-key map (kbd "T") 'gited-do-sync-with-trunk)
(define-key map (kbd "M") 'gited-merge-branch)
(define-key map (kbd "c") 'gited-checkout-branch)
(define-key map (kbd "v") 'gited-visit-branch-sources)
- [elpa] externals/gited 8f6722e 66/73: * gited.el: Bump version to 0.5.4, (continued)
- [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, 2020/11/29
- [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 <=
- [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
- [elpa] externals/gited 09d3586 28/73: Show example screenshots, Stefan Monnier, 2020/11/29
- [elpa] externals/gited 1250818 30/73: Use proper name for the branch column according with gited-ref-kind, Stefan Monnier, 2020/11/29
- [elpa] externals/gited ffa55f4 65/73: * .travis.yml: Add recipes to test for Emacs 25.3 and Emacs 26.2, Stefan Monnier, 2020/11/29