Skip to content

Commit

Permalink
Add option to skipp or overwrite all mapped paths when importing a di…
Browse files Browse the repository at this point in the history
…rectory
  • Loading branch information
MariusDoe committed Jul 3, 2024
1 parent 350dbd1 commit e9f429a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,47 @@
importing
importDirectory: aReference
| basePath |
basePath := (self
requestPathWithSuffix: nil
title: 'Base path for assets in the repository:') ifNil: [^ self].
| optionIfMapped basePath |
optionIfMapped := nil.
basePath := self initialPathRequestAnswerWithSuffix: nil.
[| askAgain mappedPaths |
basePath := (SquotPathUtilities
requestAbsolute: 'Base path for assets in the repository:'
initialAnswer: basePath)
ifNil: [^ self].
askAgain := false.
mappedPaths := ((aReference allFiles
collect: [:each | basePath resolve: (each path relativeTo: aReference path)])
reject: [:each | self activeWorkingCopy isUnmappedPath: each])
collect: [:each | SquotPathUtilities asString: each].
mappedPaths ifNotEmpty: [| answer |
answer := UIManager default
chooseOptionFrom: {
'Choose a different base path'.
'Skip taken paths'.
'Overwrite taken paths (if possible)'.
'Ask for each taken path'.
'Cancel'.
}
values: {#different. #skip. #overwrite. #ask. #cancel}
title: (('{1} paths' format: {mappedPaths size}) asText
addAttribute: (PluggableTextAttribute evalBlock: [
self inform: (mappedPaths joinSeparatedBy: String cr)]);
yourself), ' inside the base path are already taken.'.
answer caseOf: {
[#different] -> [askAgain := true].
[#skip] -> [optionIfMapped := #skip].
[#overwrite] -> [optionIfMapped := #overwrite].
[#ask] -> ["fall through"].
[#cancel] -> [^ self].
}].
askAgain] whileTrue.
aReference allFiles do: [:each |
self importFile: each getPath: [basePath resolve: (each path relativeTo: aReference path)]].
self importFile: each getPath: [| relativePath answer |
relativePath := each path relativeTo: aReference path.
answer := self activeWorkingCopy
getUnmappedPathFrom: (basePath resolve: relativePath)
withTitle: ('Path in the respository for the imported asset {1}:' format: {relativePath})
additionalOptions: {'Skip this file' -> #skip}
optionIfMapped: [optionIfMapped].
answer ifNil: [^ self "cancel entire directory import"].
answer = #skip ifTrue: [nil] ifFalse: [answer]]].
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"defaultFileNameFor:" : "mad 10/21/2023 23:08",
"defaultPath" : "mad 10/19/2023 12:08",
"formatFileName:" : "mad 10/21/2023 23:11",
"importDirectory:" : "mad 10/19/2023 13:53",
"importDirectory:" : "mad 7/3/2024 17:13",
"importFile:" : "mad 10/19/2023 13:52",
"importFile:getPath:" : "mad 4/5/2024 19:49",
"importMapper:fromStream:" : "mad 10/23/2023 14:43",
Expand Down

0 comments on commit e9f429a

Please sign in to comment.