Commit 0f1137a5 authored by Jonas Bernoulli's avatar Jonas Bernoulli Committed by Noam Postavsky

magit-credential-hook: new hook

parent 7eb90d15
......@@ -685,6 +685,9 @@ Return the matched string suffixed with \": \", if needed."
((string-suffix-p ":" prompt) (concat prompt " "))
(t (concat prompt ": "))))))
(defvar magit-credential-hook nil
"Hook run before Git needs credentials.")
(defun magit-process-wait ()
(while (and magit-this-process
(eq (process-status magit-this-process) 'run))
......
......@@ -116,6 +116,7 @@ then read the remote."
(interactive (list (or (magit-get-remote)
(magit-read-remote "Fetch remote"))
(magit-fetch-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "fetch" remote args))
;;;###autoload
......@@ -123,12 +124,14 @@ then read the remote."
"Fetch from another repository."
(interactive (list (magit-read-remote "Fetch remote")
(magit-fetch-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "fetch" remote args))
;;;###autoload
(defun magit-fetch-all (&optional args)
"Fetch from all configured remotes."
(interactive (list (magit-fetch-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "remote" "update" args))
;;; Pull
......@@ -147,6 +150,7 @@ then read the remote."
(defun magit-pull-current (remote branch &optional args)
"Fetch and merge into current branch."
(interactive (magit-pull-read-args t))
(run-hooks 'magit-credential-hook)
(magit-run-git-with-editor "pull" args
(and (not (equal remote (magit-get-remote)))
(not (equal branch (magit-get-remote-branch)))
......@@ -156,6 +160,7 @@ then read the remote."
(defun magit-pull (remote branch &optional args)
"Fetch from another repository and merge a fetched branch."
(interactive (magit-pull-read-args))
(run-hooks 'magit-credential-hook)
(magit-run-git-with-editor "pull" args remote branch))
(defun magit-pull-read-args (&optional use-upstream)
......@@ -204,6 +209,7 @@ If the upstream isn't set, then read the remote branch.
If `magit-push-always-verify' is not nil, however, always read
the remote branch."
(interactive (magit-push-read-args t))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert
"push" "-v" args remote
(if remote-branch
......@@ -304,6 +310,7 @@ not exist, then push to \"origin\". If that also doesn't exist
then raise an error. The local branch is pushed to the remote
branch with the same name."
(interactive (list (magit-push-arguments)))
(run-hooks 'magit-credential-hook)
(-if-let (branch (magit-get-current-branch))
(-if-let (remote (or (magit-remote-p (magit-get "magit.pushRemote"))
(magit-remote-p "origin")))
......@@ -318,6 +325,7 @@ This runs `git push -v'. What is being pushed depends on various
Git variables as described in the `git-push(1)' and `git-config(1)'
manpages."
(interactive (list (magit-push-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "push" "-v" args))
;;;###autoload
......@@ -326,6 +334,7 @@ manpages."
If multiple remotes exit, then read one from the user.
If just one exists, use that without requiring confirmation."
(interactive (list (magit-read-remote "Push matching branches to" nil t)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "push" "-v" args remote ":"))
(defun magit-push-tags (remote &optional args)
......@@ -335,6 +344,7 @@ for a remote, offering the remote configured for the current
branch as default."
(interactive (list (magit-read-remote "Push tags to remote" nil t)
(magit-push-arguments)))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "push" remote "--tags" args))
;;;###autoload
......@@ -343,9 +353,9 @@ branch as default."
(interactive
(let ((tag (magit-read-tag "Push tag")))
(list tag (magit-read-remote (format "Push %s to remote" tag) nil t))))
(run-hooks 'magit-credential-hook)
(magit-run-git-async-no-revert "push" remote tag))
;;; Email
;;;###autoload (autoload 'magit-patch-popup "magit-remote" nil t)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment