Skip to content

Commit f644a5c

Browse files
authored
Revert "Switch pre-commit hook to CLI (#959)" (#970)
* Revert "Switch pre-commit hook to CLI (#959)" This reverts commit 2a1ad18. * v2.3
1 parent f0b3668 commit f644a5c

6 files changed

Lines changed: 35 additions & 85 deletions

File tree

.github/workflows/PreCommit.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,4 @@
33
repos:
44
- repo: local
55
hooks:
6-
- id: julia-formatter
7-
name: "Julia Formatter"
8-
entry: "jlfmt --inplace"
9-
pass_filenames: true
10-
always_run: false
11-
types: [file]
12-
files: \.(jl|[jq]?md)$
13-
exclude: '^test/'
14-
language: "system"
15-
- repo: meta
16-
hooks:
17-
- id: check-hooks-apply
18-
- id: check-useless-excludes
6+
- id: "julia-formatter"

.pre-commit-hooks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
- id: julia-formatter
22
name: "Julia Formatter"
3-
entry: "jlfmt --inplace"
3+
entry: "julia -e 'import JuliaFormatter: format; format(ARGS)'"
44
pass_filenames: true
55
always_run: false
66
types: [file]

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "JuliaFormatter"
22
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
3-
version = "2.2.2"
3+
version = "2.3"
44
authors = ["Dominique Luna <dluna132@gmail.com>"]
55

66
[deps]

docs/src/integrations.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ repos:
1818
# ... other repos you may have
1919
```
2020

21-
Note that it requires the `jlfmt` Pkg app to be installed with
22-
23-
```julia
24-
pkg> app add JuliaFormatter
25-
```
26-
2721
You can find a list of releases [here](https://github.com/domluna/JuliaFormatter.jl/releases).
2822
**Be sure to use the entire version string!** (You can double-check this by opening the
2923
release and looking at the part of the URL that follows `.../releases/tag/VERSION`.)

src/app.jl

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ function scandir!(files, root)
3131
elseif (@tryx(isfile(jf), false) || @tryx(islink(jf), false))
3232
# Check for .jl, .md, .jmd, .qmd files
3333
if endswith(jf, ".jl") ||
34-
endswith(jf, ".md") ||
35-
endswith(jf, ".jmd") ||
36-
endswith(jf, ".qmd")
34+
endswith(jf, ".md") ||
35+
endswith(jf, ".jmd") ||
36+
endswith(jf, ".qmd")
3737
push!(files, jf)
3838
end
3939
end
@@ -45,10 +45,10 @@ function scandir!(files, root)
4545
end
4646

4747
function panic(
48-
msg::String,
49-
err::Union{Exception,Nothing} = nothing,
50-
bt::Union{Vector{Base.StackFrame},Nothing} = nothing,
51-
)
48+
msg::String,
49+
err::Union{Exception, Nothing} = nothing,
50+
bt::Union{Vector{Base.StackFrame}, Nothing} = nothing,
51+
)
5252
printstyled(stderr, "ERROR: "; color = :red, bold = true)
5353
print(stderr, msg)
5454
if err !== nothing
@@ -315,7 +315,7 @@ function main(argv::Vector{String})
315315
format_markdown = false
316316
config_priority = false
317317
style_name = "default"
318-
format_options = Dict{Symbol,Any}()
318+
format_options = Dict{Symbol, Any}()
319319
ignore_patterns = String[]
320320

321321
paths = String[]
@@ -355,7 +355,7 @@ function main(argv::Vector{String})
355355
if i >= length(argv)
356356
return panic("expected output file argument after `-o`")
357357
end
358-
outputfile = argv[i+1]
358+
outputfile = argv[i + 1]
359359
i += 2
360360
elseif startswith(x, "--output=")
361361
m = match(r"^--output=(.+)$", x)
@@ -562,21 +562,21 @@ function main(argv::Vector{String})
562562
nfiles_str = string(length(inputfiles))
563563
options_list = (
564564
ProcessFileArgs(
565-
inputfile,
566-
file_counter,
567-
nfiles_str,
568-
print_progress,
569-
check,
570-
inplace,
571-
outputfile,
572-
input_is_stdin,
573-
stdin_filename,
574-
config_dir,
575-
format_options,
576-
diff,
577-
format_markdown,
578-
config_priority,
579-
) for (file_counter, inputfile) in enumerate(inputfiles)
565+
inputfile,
566+
file_counter,
567+
nfiles_str,
568+
print_progress,
569+
check,
570+
inplace,
571+
outputfile,
572+
input_is_stdin,
573+
stdin_filename,
574+
config_dir,
575+
format_options,
576+
diff,
577+
format_markdown,
578+
config_priority,
579+
) for (file_counter, inputfile) in enumerate(inputfiles)
580580
)
581581

582582
# Use multithreading for multiple files (only if multiple threads available)
@@ -629,7 +629,7 @@ struct ProcessFileArgs
629629
input_is_stdin::Bool
630630
stdin_filename::String
631631
config_dir::String
632-
format_options::Dict{Symbol,Any}
632+
format_options::Dict{Symbol, Any}
633633
diff::Bool
634634
format_markdown::Bool
635635
config_priority::Bool
@@ -739,8 +739,8 @@ function process_file(args::ProcessFileArgs)
739739
if args.outputfile == "" || args.outputfile == "-"
740740
Output(:stdout, "", stdout, false, false)
741741
elseif isfile(args.outputfile) &&
742-
!args.input_is_stdin &&
743-
samefile(args.outputfile, args.inputfile)
742+
!args.input_is_stdin &&
743+
samefile(args.outputfile, args.inputfile)
744744
if args.print_progress
745745
@lock print_lock begin
746746
buf = IOBuffer()
@@ -764,7 +764,7 @@ function process_file(args::ProcessFileArgs)
764764
effective_options = if args.inputfile != "-"
765765
# Find and load .JuliaFormatter.toml config
766766
config_nt = find_config_file(args.inputfile)
767-
config_dict = Dict{Symbol,Any}(Symbol(k) => v for (k, v) in pairs(config_nt))
767+
config_dict = Dict{Symbol, Any}(Symbol(k) => v for (k, v) in pairs(config_nt))
768768
# Merge: by default, command line options override config file
769769
# If --prioritize-config-file is set, config file options override command line
770770
if args.config_priority
@@ -781,7 +781,7 @@ function process_file(args::ProcessFileArgs)
781781
# Try to find config file recursively from the directory
782782
find_config_file(args.config_dir)
783783
end
784-
config_dict = Dict{Symbol,Any}(Symbol(k) => v for (k, v) in pairs(config_nt))
784+
config_dict = Dict{Symbol, Any}(Symbol(k) => v for (k, v) in pairs(config_nt))
785785
if args.config_priority
786786
merge(args.format_options, config_dict)
787787
else
@@ -795,9 +795,9 @@ function process_file(args::ProcessFileArgs)
795795
if args.inputfile != "-"
796796
ignore_patterns = get(effective_options, :ignore, String[])
797797
if any(
798-
pattern -> occursin(Glob.FilenameMatch("*$pattern"), args.inputfile),
799-
ignore_patterns,
800-
)
798+
pattern -> occursin(Glob.FilenameMatch("*$pattern"), args.inputfile),
799+
ignore_patterns,
800+
)
801801
# Skip ignored files
802802
if args.print_progress
803803
@lock print_lock begin

0 commit comments

Comments
 (0)