[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/gited 1237832: Prune deleted remote branches
From: |
Tino Calancha |
Subject: |
[elpa] scratch/gited 1237832: Prune deleted remote branches |
Date: |
Wed, 7 Jun 2017 21:05:40 -0400 (EDT) |
branch: scratch/gited
commit 12378326cd5d3c89f193e596cd9ac85cb1b6efd6
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>
Prune deleted remote branches
Add user option to control whether if deleted remote
branches must be removed.
* gited.el (gited--last-remote-prune): New variable.
(gited-prune-remotes): New user option.
(gited-remote-prune): New defun.
(gited-list-branches): Call `gited-remote-prune' according
with `gited-prune-remotes' when we are not listing local branches.
---
packages/gited/gited.el | 94 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 61 insertions(+), 33 deletions(-)
diff --git a/packages/gited/gited.el b/packages/gited/gited.el
index 07cfb9a..ffa98c9 100644
--- a/packages/gited/gited.el
+++ b/packages/gited/gited.el
@@ -10,9 +10,9 @@
;; Compatibility: GNU Emacs: 24.4
;; Version: 0.2.0
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
-;; Last-Updated: Wed Jun 07 17:24:04 JST 2017
+;; Last-Updated: Thu Jun 08 09:36:32 JST 2017
;; By: calancha
-;; Update #: 645
+;; Update #: 646
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
@@ -58,31 +58,32 @@
;;
;; Internal variables defined here:
;;
-;; `gited--hide-details-set', `gited--op',
-;; `gited--revert-commit', `gited--running-async-op',
-;; `gited-actual-switches', `gited-after-change-hook',
-;; `gited-author-face', `gited-author-idx',
-;; `gited-bisect-buf-name', `gited-bisect-buffer',
-;; `gited-bisect-buffer', `gited-bisect-output-name',
-;; `gited-branch-after-op', `gited-branch-alist',
-;; `gited-branch-idx', `gited-branch-name-face',
-;; `gited-buffer', `gited-buffer-name',
-;; `gited-commit-idx', `gited-commit-msg-face',
-;; `gited-current-branch', `gited-date-idx',
-;; `gited-date-regexp', `gited-date-time-face',
-;; `gited-del-char', `gited-deletion-branch-face',
-;; `gited-deletion-face', `gited-edit-commit-mode-map',
-;; `gited-flag-mark-face', `gited-flag-mark-line-face',
-;; `gited-header', `gited-list-format',
-;; `gited-list-refs-format-command', `gited-log-buffer',
-;; `gited-mark-col-size', `gited-mark-face',
-;; `gited-mark-idx', `gited-marker-char',
-;; `gited-mode', `gited-mode-map',
-;; `gited-modified-branch', `gited-new-or-deleted-files-re',
-;; `gited-op-string', `gited-original-buffer',
-;; `gited-output-buffer', `gited-output-buffer-name',
-;; `gited-re-mark', `gited-ref-kind',
-;; `gited-section-highlight-face', `gited-toplevel-dir'.
+;; `gited--hide-details-set', `gited--last-remote-prune',
+;; `gited--op', `gited--revert-commit',
+;; `gited--running-async-op', `gited-actual-switches',
+;; `gited-after-change-hook', `gited-author-face',
+;; `gited-author-idx', `gited-bisect-buf-name',
+;; `gited-bisect-buffer', `gited-bisect-buffer',
+;; `gited-bisect-output-name', `gited-branch-after-op',
+;; `gited-branch-alist', `gited-branch-idx',
+;; `gited-branch-name-face', `gited-buffer',
+;; `gited-buffer-name', `gited-commit-idx',
+;; `gited-commit-msg-face', `gited-current-branch',
+;; `gited-date-idx', `gited-date-regexp',
+;; `gited-date-time-face', `gited-del-char',
+;; `gited-deletion-branch-face', `gited-deletion-face',
+;; `gited-edit-commit-mode-map', `gited-flag-mark-face',
+;; `gited-flag-mark-line-face', `gited-header',
+;; `gited-list-format', `gited-list-refs-format-command',
+;; `gited-log-buffer', `gited-mark-col-size',
+;; `gited-mark-face', `gited-mark-idx',
+;; `gited-marker-char', `gited-mode',
+;; `gited-mode-map', `gited-modified-branch',
+;; `gited-new-or-deleted-files-re', `gited-op-string',
+;; `gited-original-buffer', `gited-output-buffer',
+;; `gited-output-buffer-name', `gited-re-mark',
+;; `gited-ref-kind', `gited-section-highlight-face',
+;; `gited-toplevel-dir'.
;;
;; Coustom variables defined here:
;;
@@ -92,9 +93,10 @@
;; `gited-date-format', `gited-delete-unmerged-branches',
;; `gited-expert', `gited-patch-options',
;; `gited-patch-program', `gited-protected-branches',
-;; `gited-reset-mode', `gited-short-log-cmd',
-;; `gited-show-commit-hash', `gited-switches',
-;; `gited-use-header-line', `gited-verbose'.
+;; `gited-prune-remotes', `gited-reset-mode',
+;; `gited-short-log-cmd', `gited-show-commit-hash',
+;; `gited-switches', `gited-use-header-line',
+;; `gited-verbose'.
;;
;; Macros defined here:
;;
@@ -179,9 +181,10 @@
;; `gited-modified-files-p', `gited-next-branch',
;; `gited-number-of-commits', `gited-prev-branch',
;; `gited-print-entry', `gited-remember-marks',
-;; `gited-remote-repository-p', `gited-repeat-over-lines',
-;; `gited-stashes', `gited-tabulated-list-entries',
-;; `gited-trunk-branches', `gited-untracked-files'.
+;; `gited-remote-prune', `gited-remote-repository-p',
+;; `gited-repeat-over-lines', `gited-stashes',
+;; `gited-tabulated-list-entries', `gited-trunk-branches',
+;; `gited-untracked-files'.
;;
;; Faces defined here:
;;
@@ -449,6 +452,17 @@ with a prefix."
:type 'boolean
:group 'gited)
+(defvar-local gited--last-remote-prune nil "Time when was run
`gited-remote-prune'.")
+(put 'gited--last-remote-prune 'permanent-local t)
+
+(defcustom gited-prune-remotes 'daily
+ "Whether if remove references to deleted remote branches."
+ :type '(choice
+ (const :tag "Never" nil)
+ (const :tag "Always" t)
+ (const :tag "daily" daily))
+ :group 'gited)
+
(defcustom gited-current-branch-face 'font-lock-keyword-face
"Face used for displaying current checkout branch."
:type 'face
@@ -1131,6 +1145,12 @@ g = merged, k = keep): "
(message "Reseted --%s '%s' to '%s'!" mode branch commit)
(error "Cannot reset --%s '%s' to '%s'" mode branch commit)))))
+(defun gited-remote-prune ()
+ "Remove references to deleted remote branches."
+ (setq gited--last-remote-prune (current-time))
+ (message "Prunning remote branches ...")
+ (gited-git-command '("fetch" "--all" "--prune")))
+
(defun gited-delete-branch (branch &optional force)
"Delete branch BRANCH.
BRANCH default to the branch at current line.
@@ -3189,6 +3209,14 @@ in the active region."
;; Ignore dired-hide-details-* value of invisible text property by
default.
(when (eq buffer-invisibility-spec t)
(setq buffer-invisibility-spec (list t)))
+ ;; Check if we must prune remotes.
+ (when (and (not (equal gited-ref-kind "local"))
+ (or (eq t gited-prune-remotes)
+ (and (eq 'daily gited-prune-remotes)
+ (or (not gited--last-remote-prune)
+ (time-less-p (seconds-to-time (* 24 60 60))
+ (time-subtract (current-time)
gited--last-remote-prune))))))
+ (gited-remote-prune))
(gited-tabulated-list-entries)
(tabulated-list-print)
;; Go to `gited-current-branch' when it is shown.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] scratch/gited 1237832: Prune deleted remote branches,
Tino Calancha <=