-
Notifications
You must be signed in to change notification settings - Fork 7
added --cached option to scan for cached git files, useful in pre-com… #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,15 @@ | |
(clojure.string/split #"\000") | ||
set))) | ||
|
||
(defn find-files-git-cached | ||
[] | ||
(let [{:keys [exit out err]} (clojure.java.shell/sh "git" "diff" | ||
"--cached" "--name-only")] | ||
(when (not= exit 0) (throw (ex-info "git diff --cached failed" {:err err}))) | ||
(->> (clojure.string/split out #"\n") | ||
(filter #(re-matches #".*\.(clj|cljs|cljc|cljx|cljs\.hl|boot)$" %)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also the duplication concerns me, you need to add new file extensions in two places |
||
set))) | ||
|
||
(defn find-files-source | ||
[] | ||
(clojure.set/union (bc/get-env :source-paths) (bc/get-env :resource-paths))) | ||
|
@@ -61,11 +70,13 @@ Specify the operation using the --mode parameter: | |
f files VAL #{str} "The list of files or directories to format" | ||
s source bool "Automatically scan for files in boot source-paths and resource-paths" | ||
g git bool "Automatically scan for files in current git repository" | ||
c cached bool "Automatically scan for cached files in current git repository" | ||
o options OPTS edn "zprint options"] | ||
(let [mode (or mode :print) | ||
files (cond-> files | ||
source (clojure.set/union (find-files-source)) | ||
git (clojure.set/union (find-files-git)))] | ||
git (clojure.set/union (find-files-git)) | ||
cached (clojure.set/union (find-files-git-cached)))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
|
||
(assert (seq files) "At least one filename needs to be provided.") | ||
(assert (#{:print :list :diff :overwrite} mode) "Invalid mode") | ||
(assert (or (not= :overwrite mode) really) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you use the
-z
option here, as withls-files
?