fix: user/system git config breaking straight installer

Fix: #6346
This commit is contained in:
Henrik Lissner 2022-05-02 02:11:52 +02:00
parent 0597466261
commit 3b789752a3
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -111,76 +111,80 @@ uses a straight or package.el command directly).")
;;; Bootstrappers ;;; Bootstrappers
(defun doom--ensure-straight (recipe pin) (defun doom--ensure-straight (recipe pin)
(let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el")) (letenv! (("GIT_CONFIG" nil)
(repo-url (concat "http" (if gnutls-verify-error "s") ("GIT_CONFIG_NOSYSTEM" "1")
"://github.com/" ("GIT_CONFIG_GLOBAL" (or (getenv "DOOMGITCONFIG")
(or (plist-get recipe :repo) "raxod502/straight.el"))) "/dev/null")))
(branch (or (plist-get recipe :branch) straight-repository-branch)) (let ((repo-dir (doom-path straight-base-dir "straight/repos/straight.el"))
(call (if doom-debug-p (repo-url (concat "http" (if gnutls-verify-error "s")
"://github.com/"
(or (plist-get recipe :repo) "raxod502/straight.el")))
(branch (or (plist-get recipe :branch) straight-repository-branch))
(call (if doom-debug-p
(lambda (&rest args)
(print! "%s" (cdr (apply #'doom-call-process args))))
(lambda (&rest args) (lambda (&rest args)
(print! "%s" (cdr (apply #'doom-call-process args)))) (apply #'doom-call-process args)))))
(lambda (&rest args) (unless (file-directory-p repo-dir)
(apply #'doom-call-process args))))) (save-match-data
(unless (file-directory-p repo-dir) (unless (executable-find "git")
(save-match-data (user-error "Git isn't present on your system. Cannot proceed."))
(unless (executable-find "git") (let* ((version (cdr (doom-call-process "git" "version")))
(user-error "Git isn't present on your system. Cannot proceed.")) (version
(let* ((version (cdr (doom-call-process "git" "version"))) (and (string-match "\\_<[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)\\_>" version)
(version (match-string 0 version))))
(and (string-match "\\_<[0-9]+\\.[0-9]+\\(\\.[0-9]+\\)\\_>" version) (if version
(match-string 0 version)))) (when (version< version "2.23")
(if version (user-error "Git %s detected! Doom requires git 2.23 or newer!"
(when (version< version "2.23") version)))))
(user-error "Git %s detected! Doom requires git 2.23 or newer!" (print! (start "Installing straight..."))
version))))) (print-group!
(print! (start "Installing straight...")) (cl-destructuring-bind (depth . options)
(print-group! (doom-enlist straight-vc-git-default-clone-depth)
(cl-destructuring-bind (depth . options) (let ((branch-switch (if (memq 'single-branch options)
(doom-enlist straight-vc-git-default-clone-depth) "--single-branch"
(let ((branch-switch (if (memq 'single-branch options) "--no-single-branch")))
"--single-branch" (cond
"--no-single-branch"))) ((eq 'full depth)
(cond (funcall call "git" "clone" "--origin" "origin"
((eq 'full depth) branch-switch repo-url repo-dir))
(funcall call "git" "clone" "--origin" "origin" ((integerp depth)
branch-switch repo-url repo-dir)) (if (null pin)
((integerp depth) (progn
(if (null pin) (when (file-directory-p repo-dir)
(progn (delete-directory repo-dir 'recursive))
(when (file-directory-p repo-dir) (funcall call "git" "clone" "--origin" "origin" repo-url
(delete-directory repo-dir 'recursive)) "--no-checkout" repo-dir
(funcall call "git" "clone" "--origin" "origin" repo-url "--depth" (number-to-string depth)
"--no-checkout" repo-dir branch-switch
"--no-tags"
"--branch" straight-repository-branch))
(make-directory repo-dir 'recursive)
(let ((default-directory repo-dir))
(funcall call "git" "init")
(funcall call "git" "branch" "-m" straight-repository-branch)
(funcall call "git" "remote" "add" "origin" repo-url
"--master" straight-repository-branch)
(funcall call "git" "fetch" "origin" pin
"--depth" (number-to-string depth) "--depth" (number-to-string depth)
branch-switch "--no-tags")
"--no-tags" (funcall call "git" "reset" "--hard" pin)))))))))
"--branch" straight-repository-branch)) (require 'straight (concat repo-dir "/straight.el"))
(make-directory repo-dir 'recursive) (doom-log "Initializing recipes")
(let ((default-directory repo-dir)) (mapc #'straight-use-recipes
(funcall call "git" "init") '((org-elpa :local-repo nil)
(funcall call "git" "branch" "-m" straight-repository-branch) (melpa :type git :host github
(funcall call "git" "remote" "add" "origin" repo-url :repo "melpa/melpa"
"--master" straight-repository-branch) :build nil)
(funcall call "git" "fetch" "origin" pin (gnu-elpa-mirror :type git :host github
"--depth" (number-to-string depth) :repo "emacs-straight/gnu-elpa-mirror"
"--no-tags") :build nil)
(funcall call "git" "reset" "--hard" pin))))))))) (el-get :type git :host github
(require 'straight (concat repo-dir "/straight.el")) :repo "dimitri/el-get"
(doom-log "Initializing recipes") :build nil)
(mapc #'straight-use-recipes (emacsmirror-mirror :type git :host github
'((org-elpa :local-repo nil) :repo "emacs-straight/emacsmirror-mirror"
(melpa :type git :host github :build nil))))))
:repo "melpa/melpa"
:build nil)
(gnu-elpa-mirror :type git :host github
:repo "emacs-straight/gnu-elpa-mirror"
:build nil)
(el-get :type git :host github
:repo "dimitri/el-get"
:build nil)
(emacsmirror-mirror :type git :host github
:repo "emacs-straight/emacsmirror-mirror"
:build nil)))))
(defun doom--ensure-core-packages (packages) (defun doom--ensure-core-packages (packages)
(doom-log "Installing core packages") (doom-log "Installing core packages")