feat: don't rename capitalization

pull/7184/head^2
Junyi Du 2022-11-07 11:54:24 +08:00 committed by Tienson Qin
parent a1605f301f
commit 70b41ad7d1
2 changed files with 13 additions and 6 deletions

View File

@ -4,7 +4,8 @@
"For conversion logic between old version and new version"
(:require [logseq.graph-parser.util :as gp-util]
[frontend.util.fs :as fs-util]
[frontend.handler.config :refer [set-config!]]))
[frontend.handler.config :refer [set-config!]]
[frontend.util :as util]))
(defn write-filename-format!
"Return:
@ -77,11 +78,16 @@
;; It's about user's own data management decision and should be handled
;; by user manually.
;; the 'expected' title of the user when updating from the previous format, or title will be broken in new format
(or (when (and (nil? prop-title)
(not= old-format new-format))
(calc-previous-name old-format new-format file-body))
;; if no break-change conversion triggered, check if file name is in an informal / outdated style.
(calc-current-name new-format file-body prop-title)))
(let [ret (or (when (and (nil? prop-title)
(not= old-format new-format))
(calc-previous-name old-format new-format file-body))
;; if no break-change conversion triggered, check if file name is in an informal / outdated style.
(calc-current-name new-format file-body prop-title))]
(when (and ret
;; Return only when the target is different from the original file body, not only capitalization difference
(not= (util/page-name-sanity-lc (:target ret))
(util/page-name-sanity-lc file-body)))
ret)))
(defn calc-rename-target
"Return the renaming status and new file body to recover the original title of the file in previous version.

View File

@ -102,6 +102,7 @@
(deftest rename-tests
;; z: new title structure; x: old ver title; y: title property (if available)
(are [x y z] (= z (#'conversion-handler/calc-rename-target-impl :legacy :triple-lowbar x y))
"aaBBcc" "aabbcc" nil
"aaa.bbb.ccc" "aaa/bbb/ccc" {:status :informal,
:target "aaa___bbb___ccc",
:old-title "aaa/bbb/ccc",