44(require fancy-app
55 json
66 racket/cmdline
7- racket/file
87 racket/format
9- racket/hash
10- (except-in racket/list range)
118 racket/logging
129 racket/match
1310 racket/path
2724 resyntax/default-recommendations
2825 resyntax/private/file-group
2926 resyntax/private/github
30- resyntax/private/limiting
31- resyntax/private/line-replacement
3227 resyntax/private/refactoring-result
3328 resyntax/private/source
3429 resyntax/private/string-indent
35- resyntax/private/syntax-replacement
36- (only-in racket/list append-map empty? shuffle))
30+ resyntax/private/syntax-replacement)
3731
3832
3933;@----------------------------------------------------------------------------------------------------
4034
4135
4236(define-enum-type resyntax-output-format (plain-text github-pull-request-review git-commit-message))
37+ (define-enum-type resyntax-fix-method (modify-files create-multiple-git-commits))
4338(define-record-type resyntax-analyze-options (targets suite output-format output-destination))
39+
40+
4441(define-record-type resyntax-fix-options
45- (targets suite output-format max-fixes max-modified-files max-modified-lines max-pass-count))
42+ (targets
43+ suite
44+ fix-method
45+ output-format
46+ max-fixes
47+ max-modified-files
48+ max-modified-lines
49+ max-pass-count))
4650
4751
4852(define all-lines (range-set (unbounded-range #:comparator natural<=>)))
@@ -114,6 +118,7 @@ determined by the GITHUB_REPOSITORY and GITHUB_REF environment variables."
114118 (define suite default-recommendations)
115119 (define (add-target! target)
116120 (vector-builder-add targets target))
121+ (define fix-method modify-files)
117122 (define output-format plain-text)
118123 (define max-fixes +inf.0 )
119124 (define max-pass-count 10 )
@@ -137,10 +142,6 @@ determined by the GITHUB_REPOSITORY and GITHUB_REF environment variables."
137142 "An installed package to fix. "
138143 (add-target! (package-file-group pkgname)))
139144
140- ("--output-as-commit-message "
141- "Report results in the form of a Git commit message printed to stdout. "
142- (set! output-format git-commit-message))
143-
144145 ("--local-git-repository "
145146 repopath baseref
146147 "A Git repository to search for modified files to fix. The repopath argument is a directory
@@ -151,6 +152,14 @@ changed relative to baseref are analyzed and fixed."
151152
152153 #:once-each
153154
155+ ("--create-multiple-commits "
156+ "Modify files by creating a series of individual Git commits. "
157+ (set! fix-method create-multiple-git-commits))
158+
159+ ("--output-as-commit-message "
160+ "Report results in the form of a Git commit message printed to stdout. "
161+ (set! output-format git-commit-message))
162+
154163 ("--refactoring-suite "
155164 modpath
156165 suite-name
@@ -183,6 +192,7 @@ are needed when applying a fix unlocks further fixes."
183192
184193 (resyntax-fix-options #:targets (build-vector targets)
185194 #:suite suite
195+ #:fix-method fix-method
186196 #:output-format output-format
187197 #:max-fixes max-fixes
188198 #:max-modified-files max-modified-files
@@ -261,6 +271,7 @@ For help on these, use 'analyze --help' or 'fix --help'."
261271
262272(define (resyntax-fix-run)
263273 (define options (resyntax-fix-parse-command-line))
274+ (define fix-method (resyntax-fix-options-fix-method options))
264275 (define output-format (resyntax-fix-options-output-format options))
265276 (define sources (file-groups-resolve (resyntax-fix-options-targets options)))
266277 (define max-modified-files (resyntax-fix-options-max-modified-files options))
@@ -272,7 +283,11 @@ For help on these, use 'analyze --help' or 'fix --help'."
272283 #:max-passes (resyntax-fix-options-max-pass-count options)
273284 #:max-modified-sources max-modified-files
274285 #:max-modified-lines max-modified-lines))
275- (resyntax-analysis-write-file-changes! analysis)
286+ (match fix-method
287+ [(== modify-files)
288+ (resyntax-analysis-write-file-changes! analysis)]
289+ [(== create-multiple-git-commits)
290+ (resyntax-analysis-commit-fixes! analysis)])
276291 (match output-format
277292 [(== git-commit-message)
278293 (resyntax-fix-print-git-commit-message analysis)]
0 commit comments