Skip to content

Commit

Permalink
feat: add git dpth to options
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 18, 2023
1 parent c5b59d7 commit 3311e91
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions unit-picker/src/main/kotlin/cc/unitmesh/pick/SimpleCodePicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,22 @@ class SimpleCodePicker(private val config: PickerOption) : CodePicker {
Files.createDirectories(tempGitDir)
}

val codeDir = checkoutCode(config.url, config.branch, tempGitDir)
val codeDir = checkoutCode(config.url, config.branch, tempGitDir, config.gitDepth)
.toFile().canonicalFile

logger.info("start config")

val languageWorker = LanguageWorker()
val workerManager = WorkerManager(WorkerContext(
config.codeContextStrategies,
config.codeQualityTypes,
config.builderConfig,
pureDataFileName = config.pureDataFileName(),
config.completionTypes,
config.maxCompletionInOneFile
))
val workerManager = WorkerManager(
WorkerContext(
config.codeContextStrategies,
config.codeQualityTypes,
config.builderConfig,
pureDataFileName = config.pureDataFileName(),
config.completionTypes,
config.maxCompletionInOneFile
)
)
val walkdirChannel = Channel<FileJob>()
val summary = mutableListOf<Instruction>()

Expand Down Expand Up @@ -132,7 +134,7 @@ class SimpleCodePicker(private val config: PickerOption) : CodePicker {
return "$host/$owner/$repo"
}

fun checkoutCode(url: String, branch: String, baseDir: Path): Path {
fun checkoutCode(url: String, branch: String, baseDir: Path, depth: Int): Path {
if (!gitUrlRegex.matches(url)) {
return Path.of(url)
}
Expand All @@ -150,6 +152,7 @@ class SimpleCodePicker(private val config: PickerOption) : CodePicker {
repository = url,
branch = branch,
workdir = targetDir.parent.absolutePathString(),
fetchDepth = depth
)

try {
Expand Down

0 comments on commit 3311e91

Please sign in to comment.