mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix(sync): diff when a page has been created both on local and remote
Related to https://github.com/logseq/logseq/issues/445.
This commit is contained in:
@@ -104,18 +104,6 @@
|
|||||||
:error
|
:error
|
||||||
false))
|
false))
|
||||||
|
|
||||||
(defn show-diff-error!
|
|
||||||
[_repo-url]
|
|
||||||
(notification/show!
|
|
||||||
[:p
|
|
||||||
[:span.text-gray-700.font-bold.mr-2
|
|
||||||
"Please resolve the diffs if any."]
|
|
||||||
(ui/button
|
|
||||||
"Go to diff"
|
|
||||||
:href "/diff")]
|
|
||||||
:error
|
|
||||||
false))
|
|
||||||
|
|
||||||
(defn get-new-token
|
(defn get-new-token
|
||||||
[repo]
|
[repo]
|
||||||
(when-let [installation-id (-> (filter
|
(when-let [installation-id (-> (filter
|
||||||
@@ -352,15 +340,29 @@
|
|||||||
(git-handler/set-git-error! repo-url error))))
|
(git-handler/set-git-error! repo-url error))))
|
||||||
(state/set-changed-files! repo-url nil)))
|
(state/set-changed-files! repo-url nil)))
|
||||||
(p/catch (fn [error]
|
(p/catch (fn [error]
|
||||||
|
(println "Git pull error:")
|
||||||
|
(js/console.error error)
|
||||||
(git-handler/set-git-status! repo-url :merge-failed)
|
(git-handler/set-git-status! repo-url :merge-failed)
|
||||||
(git-handler/set-git-error! repo-url error)
|
(git-handler/set-git-error! repo-url error)
|
||||||
(notification/show!
|
(git-handler/get-latest-commit
|
||||||
[:p.content
|
repo-url
|
||||||
"Failed to merge, please "
|
(fn [commit]
|
||||||
[:span.text-gray-700.font-bold
|
(let [local-oid (gobj/get commit "oid")
|
||||||
"resolve any diffs first."]]
|
remote-oid (db/get-key-value repo-url
|
||||||
:error)
|
:git/remote-latest-commit)]
|
||||||
(route-handler/redirect! {:to :diff}))))))
|
(p/let [result (git/get-local-diffs repo-url local-oid remote-oid)]
|
||||||
|
(if (seq result)
|
||||||
|
(do
|
||||||
|
(notification/show!
|
||||||
|
[:p.content
|
||||||
|
"Failed to merge, please "
|
||||||
|
[:span.text-gray-700.font-bold
|
||||||
|
"resolve any diffs first."]]
|
||||||
|
:error)
|
||||||
|
(route-handler/redirect! {:to :diff}))
|
||||||
|
(push repo-url {:commit-push? true
|
||||||
|
:force? true
|
||||||
|
:commit-message "Merge push without diffed files"})))))))))))
|
||||||
(p/catch (fn [error]
|
(p/catch (fn [error]
|
||||||
(println "Pull error:" (str error))
|
(println "Pull error:" (str error))
|
||||||
(js/console.error error)
|
(js/console.error error)
|
||||||
@@ -383,10 +385,11 @@
|
|||||||
nil)))))))))))
|
nil)))))))))))
|
||||||
|
|
||||||
(defn push
|
(defn push
|
||||||
[repo-url {:keys [commit-message fallback? diff-push? force?]
|
[repo-url {:keys [commit-message fallback? diff-push? commit-push? force?]
|
||||||
:or {commit-message "Logseq auto save"
|
:or {commit-message "Logseq auto save"
|
||||||
fallback? false
|
fallback? false
|
||||||
diff-push? false
|
diff-push? false
|
||||||
|
commit-push? false
|
||||||
force? false}}]
|
force? false}}]
|
||||||
(let [status (db/get-key-value repo-url :git/status)]
|
(let [status (db/get-key-value repo-url :git/status)]
|
||||||
(when (and
|
(when (and
|
||||||
@@ -394,7 +397,7 @@
|
|||||||
(not (state/get-edit-input-id)))
|
(not (state/get-edit-input-id)))
|
||||||
(-> (p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
|
(-> (p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
|
||||||
(when (or
|
(when (or
|
||||||
force?
|
commit-push?
|
||||||
(seq files)
|
(seq files)
|
||||||
fallback?
|
fallback?
|
||||||
diff-push?)
|
diff-push?)
|
||||||
@@ -407,12 +410,13 @@
|
|||||||
(git-handler/set-git-status! repo-url :pushing)
|
(git-handler/set-git-status! repo-url :pushing)
|
||||||
(when-let [token (state/get-github-token repo-url)]
|
(when-let [token (state/get-github-token repo-url)]
|
||||||
(util/p-handle
|
(util/p-handle
|
||||||
(git/push repo-url token)
|
(git/push repo-url token force?)
|
||||||
(fn [result]
|
(fn [result]
|
||||||
(git-handler/set-git-status! repo-url nil)
|
(git-handler/set-git-status! repo-url nil)
|
||||||
(git-handler/set-git-error! repo-url nil)
|
(git-handler/set-git-error! repo-url nil)
|
||||||
(state/set-changed-files! repo-url nil))
|
(state/set-changed-files! repo-url nil))
|
||||||
(fn [error]
|
(fn [error]
|
||||||
|
(println "Git push error: ")
|
||||||
(js/console.error error)
|
(js/console.error error)
|
||||||
(common-handler/check-changed-files-status)
|
(common-handler/check-changed-files-status)
|
||||||
(let [permission? (or (string/includes? (str error) "401")
|
(let [permission? (or (string/includes? (str error) "401")
|
||||||
@@ -621,7 +625,7 @@
|
|||||||
(when-let [repo (state/get-current-repo)]
|
(when-let [repo (state/get-current-repo)]
|
||||||
(push repo {:commit-message commit-message
|
(push repo {:commit-message commit-message
|
||||||
:fallback? false
|
:fallback? false
|
||||||
:force? true})))
|
:commit-push? true})))
|
||||||
|
|
||||||
(defn read-repair-journals!
|
(defn read-repair-journals!
|
||||||
[repo-url]
|
[repo-url]
|
||||||
|
|||||||
Reference in New Issue
Block a user