mirror of
https://github.com/logseq/logseq.git
synced 2026-06-01 19:01:22 +00:00
remove git, chokidar, rsapi
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
(ns frontend.handler.shell
|
||||
"Git related handler fns"
|
||||
(:require [electron.ipc :as ipc]
|
||||
[clojure.string :as string]
|
||||
[logseq.common.util :as common-util]
|
||||
(:require [clojure.string :as string]
|
||||
[electron.ipc :as ipc]
|
||||
[frontend.handler.notification :as notification]
|
||||
[logseq.shui.ui :as shui]
|
||||
[promesa.core :as p]
|
||||
[frontend.db :as db]
|
||||
[frontend.state :as state]
|
||||
[frontend.util :as util]))
|
||||
|
||||
(defn run-git-command!
|
||||
[command]
|
||||
(ipc/ipc :runGit {:repo (state/get-current-repo)
|
||||
:command command}))
|
||||
|
||||
(defn run-git-command2!
|
||||
[command]
|
||||
(ipc/ipc :runGitWithinCurrentGraph {:repo (state/get-current-repo)
|
||||
:command command}))
|
||||
[frontend.util :as util]
|
||||
[logseq.common.util :as common-util]))
|
||||
|
||||
(defn run-cli-command!
|
||||
[command args]
|
||||
@@ -26,17 +12,6 @@
|
||||
:args args
|
||||
:returnResult true}))
|
||||
|
||||
(defn wrap-notification!
|
||||
[command f args]
|
||||
(p/let [result (f command args)]
|
||||
(notification/show!
|
||||
(if (string/blank? result)
|
||||
[:p [:code.mr-1 (str command " " args)]
|
||||
"was executed successfully!"]
|
||||
result)
|
||||
:success
|
||||
false)))
|
||||
|
||||
(def commands-denylist
|
||||
#{"rm" "mv" "rename" "dd" ">" "command" "sudo"})
|
||||
|
||||
@@ -55,33 +30,9 @@
|
||||
[:div (str command " is too dangerous!")]
|
||||
:error)
|
||||
|
||||
(= "git" command)
|
||||
(wrap-notification! command (fn [_ args] (run-git-command! args)) args)
|
||||
|
||||
:else
|
||||
(run-cli-command! command args)))))
|
||||
|
||||
|
||||
(defn get-file-latest-git-log
|
||||
[page n]
|
||||
(when (integer? n)
|
||||
(let [file-id (:db/id (:block/file page))]
|
||||
(when-let [path (:file/path (db/entity file-id))]
|
||||
(p/let [result (run-git-command! ["log" (str "-" n) "--pretty=format:Commit: %C(auto)%h$$$%s$$$%ad" "-p" path])
|
||||
lines (->> (string/split-lines result)
|
||||
(filter #(string/starts-with? % "Commit: ")))]
|
||||
(state/pub-event! [:modal/display-file-version-selector lines path (fn [hash path] (run-git-command! ["show" (str hash ":" path)]))]))))))
|
||||
|
||||
|
||||
(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])]
|
||||
(shui/dialog-close!)
|
||||
(notification/show!
|
||||
[:div "git config successfully!"]
|
||||
:success)))
|
||||
|
||||
(defn run-cli-command-wrapper!
|
||||
[command content]
|
||||
(let [args (case command
|
||||
|
||||
Reference in New Issue
Block a user