diff options
-rw-r--r-- | emacs/custom/fcuny-git.el | 101 |
1 files changed, 61 insertions, 40 deletions
diff --git a/emacs/custom/fcuny-git.el b/emacs/custom/fcuny-git.el index b2671c6..5425bb8 100644 --- a/emacs/custom/fcuny-git.el +++ b/emacs/custom/fcuny-git.el @@ -17,46 +17,67 @@ :custom (vc-follow-symlinks t) :config - ;; if we're on darwin, we're on a work laptop, so let's make sure we - ;; use the proper `git' binary. - (when (string= system-type "darwin") - (setq magit-git-executable "/opt/twitter_mde/bin/git")) - ;; I want to see these things by default - (add-to-list 'magit-section-initial-visibility-alist '(untracked . show)) - (add-to-list 'magit-section-initial-visibility-alist '(unstaged . show)) - (add-to-list 'magit-section-initial-visibility-alist '(unpulled . show)) - (add-to-list 'magit-section-initial-visibility-alist '(unpushed . show)) - (add-to-list 'magit-section-initial-visibility-alist '(stashes . show)) - ;; no need to show the last 10 commits, 5 is enough. - (setq magit-log-section-commit-count 5) - ;; when working with source, some of the hooks are extremely - ;; expensive and don't add much values (i.e tags). Let's reduce the - ;; list to things that are actually useful. This still takes ~10 - ;; seconds when running `magit-status'. - (setq git-commit-setup-hook - '(git-commit-save-message - git-commit-turn-on-auto-fill - git-commit-turn-on-flyspell - git-commit-propertize-diff - with-editor-usage-message)) - (setq magit-refs-sections-hook - '(magit-insert-error-header - magit-insert-branch-description - magit-insert-local-branches)) - (setq magit-status-sections-hook - '(magit-insert-status-headers - magit-insert-merge-log - magit-insert-rebase-sequence - magit-insert-am-sequence - magit-insert-sequencer-sequence - magit-insert-untracked-files - magit-insert-unstaged-changes - magit-insert-staged-changes - magit-insert-stashes)) - (setq magit-status-headers-hook - '(magit-insert-error-header - magit-insert-diff-filter-header - magit-insert-head-branch-header))) + (defun fcuny/magit-settings-for-work () + "Settings to apply for work. The main monorepo at work is too large for most of the default settings with magit." + ;; if we're on darwin, we're on a work laptop, so let's make sure we + ;; use the proper `git' binary. + (setq magit-git-executable "/opt/twitter_mde/bin/git") + + ;; no need to show the last 10 commits, 5 is enough. + (setq magit-log-section-commit-count 5) + + ;; when working with source, some of the hooks are extremely + ;; expensive and don't add much values (i.e tags). Let's reduce the + ;; list to things that are actually useful. This still takes ~10 + ;; seconds when running `magit-status'. + (setq git-commit-setup-hook + '(git-commit-save-message + git-commit-turn-on-auto-fill + git-commit-turn-on-flyspell + git-commit-propertize-diff + with-editor-usage-message)) + (setq magit-refs-sections-hook + '(magit-insert-error-header + magit-insert-branch-description + magit-insert-local-branches)) + (setq magit-status-sections-hook + '(magit-insert-status-headers + magit-insert-merge-log + magit-insert-rebase-sequence + magit-insert-am-sequence + magit-insert-sequencer-sequence + magit-insert-untracked-files + magit-insert-unstaged-changes + magit-insert-staged-changes + magit-insert-stashes)) + (setq magit-status-headers-hook + '(magit-insert-error-header + magit-insert-diff-filter-header + magit-insert-head-branch-header))) + + (defun fcuny/magit-settings () + ;; Add a "latest commits" section + (magit-add-section-hook 'magit-status-sections-hook + 'magit-insert-recent-commits + nil t) + (magit-add-section-hook 'magit-status-sections-hook + 'magit-insert-unpushed-to-upstream + 'magit-insert-unpushed-to-upstream-or-recent + 'replace)) + + (when (fcuny/check-work-machine-p) + (fcuny/magit-settings-for-work) + (fcuny/magit-settings)) + + :custom + (magit-completing-read-function 'ivy-completing-read) + (magit-section-initial-visibility-alist + '((stashes . show) + (unpushed . how) + (unpulled . show) + (recent . show) + (untracked . show) + (unstaged . show)))) (use-package magit-repos :ensure nil |