mirror of https://github.com/logseq/logseq
fix: git username and email configuration
parent
9c3b11c216
commit
509697b276
|
@ -21,6 +21,11 @@
|
|||
(. fs ensureDirSync dir)
|
||||
dir)))
|
||||
|
||||
(defn dot-git-exists?
|
||||
[]
|
||||
(let [p (.join path (get-graph-path) ".git")]
|
||||
(fs/existsSync p)))
|
||||
|
||||
(defn run-git!
|
||||
[commands]
|
||||
(when-let [path (get-graph-path)]
|
||||
|
@ -73,9 +78,13 @@
|
|||
_ (add-all!)]
|
||||
(commit! message))
|
||||
(p/catch (fn [error]
|
||||
(when-not (string/blank? error)
|
||||
(utils/send-to-renderer "notification" {:type "error"
|
||||
:payload error})))))))
|
||||
(when (and (not (string/blank? error))
|
||||
;; FIXME: not sure why this happened
|
||||
(not (string/starts-with? error "fatal: not a git repository")))
|
||||
(if (string/starts-with? error "Author identity unknown")
|
||||
(utils/send-to-renderer "setGitUsernameAndEmail" {:type "git"})
|
||||
(utils/send-to-renderer "notification" {:type "error"
|
||||
:payload error}))))))))
|
||||
|
||||
(defonce quotes-regex #"\"[^\"]+\"")
|
||||
(defn wrapped-by-quotes?
|
||||
|
@ -126,8 +135,7 @@
|
|||
[]
|
||||
(when (not (state/git-auto-commit-disabled?))
|
||||
(state/clear-git-commit-interval!)
|
||||
(p/let [_ (add-all-and-commit!)]
|
||||
(let [seconds (state/get-git-commit-seconds)]
|
||||
(when (int? seconds)
|
||||
(let [interval (js/setInterval add-all-and-commit! (* seconds 1000))]
|
||||
(state/set-git-commit-interval! interval)))))))
|
||||
(let [seconds (state/get-git-commit-seconds)]
|
||||
(when (int? seconds)
|
||||
(let [interval (js/setInterval add-all-and-commit! (* seconds 1000))]
|
||||
(state/set-git-commit-interval! interval))))))
|
||||
|
|
|
@ -57,7 +57,11 @@
|
|||
(let [{:keys [type payload]} (bean/->clj data)
|
||||
type (keyword type)
|
||||
comp [:div (str payload)]]
|
||||
(notification/show! comp type false)))))
|
||||
(notification/show! comp type false))))
|
||||
|
||||
(js/window.apis.on "setGitUsernameAndEmail"
|
||||
(fn []
|
||||
(state/pub-event! [:modal/set-git-username-and-email]))))
|
||||
|
||||
(defn listen!
|
||||
[]
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
(ns frontend.components.git
|
||||
(:require [rum.core :as rum]
|
||||
[frontend.ui :as ui]
|
||||
[frontend.util :as util]
|
||||
[clojure.string :as string]
|
||||
[frontend.handler.shell :as shell]))
|
||||
|
||||
(rum/defcs set-git-username-and-email <
|
||||
(rum/local "" ::username)
|
||||
(rum/local "" ::email)
|
||||
[state]
|
||||
(let [username (get state ::username)
|
||||
email (get state ::email)]
|
||||
[:div.container
|
||||
[:div.text-lg.mb-4 "Git requires to setup your username and email address."]
|
||||
[:div.sm:flex.sm:items-start
|
||||
[:div.mt-3.text-center.sm:mt-0.sm:text-left
|
||||
[:h3#modal-headline.leading-6.font-medium
|
||||
"Your username:"]]]
|
||||
|
||||
[:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2.mb-4
|
||||
{:auto-focus true
|
||||
:on-change (fn [e]
|
||||
(reset! username (util/evalue e)))}]
|
||||
|
||||
[:div.sm:flex.sm:items-start
|
||||
[:div.mt-3.text-center.sm:mt-0.sm:text-left
|
||||
[:h3#modal-headline.leading-6.font-medium
|
||||
"Your email address:"]]]
|
||||
|
||||
[:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
|
||||
{:on-change (fn [e]
|
||||
(reset! email (util/evalue e)))}]
|
||||
|
||||
[:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse
|
||||
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
|
||||
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
|
||||
{:type "button"
|
||||
:on-click (fn []
|
||||
(let [username @username
|
||||
email @email]
|
||||
(when (and (not (string/blank? username))
|
||||
(not (string/blank? email)))
|
||||
(shell/set-git-username-and-email username email))))}
|
||||
"Submit"]]]]))
|
|
@ -12,6 +12,7 @@
|
|||
[frontend.handler.page :as page-handler]
|
||||
[frontend.components.encryption :as encryption]
|
||||
[frontend.components.shell :as shell]
|
||||
[frontend.components.git :as git-component]
|
||||
[frontend.fs.nfs :as nfs]
|
||||
[frontend.db.conn :as conn]
|
||||
[frontend.extensions.srs :as srs]
|
||||
|
@ -142,6 +143,9 @@
|
|||
(defmethod handle :modal/show [[_ content]]
|
||||
(state/set-modal! #(modal-output content)))
|
||||
|
||||
(defmethod handle :modal/set-git-username-and-email [[_ content]]
|
||||
(state/set-modal! git-component/set-git-username-and-email))
|
||||
|
||||
(defmethod handle :page/title-property-changed [[_ old-title new-title]]
|
||||
(page-handler/rename! old-title new-title))
|
||||
|
||||
|
|
|
@ -79,3 +79,12 @@
|
|||
hash]
|
||||
title]
|
||||
[:div.opacity-50 time]]))] :success false))))))
|
||||
|
||||
(defn set-git-username-and-email
|
||||
[username email]
|
||||
(p/let [r1 (run-git-command! ["config" "--global" "user.name" username])
|
||||
r2 (run-git-command! ["config" "--global" "user.email" email])]
|
||||
(state/close-modal!)
|
||||
(notification/show!
|
||||
[:div "git config successfully!"]
|
||||
:success)))
|
||||
|
|
Loading…
Reference in New Issue