Skip to content

Commit

Permalink
fix: fix typos for alla
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 8, 2023
1 parent b3386d7 commit b9e0a59
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ import org.archguard.action.checkout.helper.GitAuthHelper
import org.archguard.action.checkout.helper.RefHelper
import org.archguard.action.io.FileExt
import java.io.File
import kotlin.io.path.Path

fun executeGitCheckout(settings: GitSourceSettings) {
val git = GitCommandManager(settings.workdir + File.separator + settings.repositoryPath)
val workingDirectory = settings.workdir + File.separator + settings.repositoryPath
val git = GitCommandManager(workingDirectory)

logger.info("Working directory: {}", Path(workingDirectory).toAbsolutePath())
if (File(workingDirectory).exists()) {
FileExt.rmdir(workingDirectory)
}

FileExt.mkdir(workingDirectory)

doCheckout(git, settings)
}

fun doCheckout(git: GitCommandManager, settings: GitSourceSettings) {
val authHelper = GitAuthHelper(git, settings)

if (File(git.workingDirectory).exists()) {
FileExt.rmdir(git.workingDirectory)
}

FileExt.mkdir(git.workingDirectory)

authHelper.configureTempGlobalConfig()

git.config("safe.directory", git.workingDirectory, true, true)
Expand All @@ -36,8 +39,8 @@ fun doCheckout(git: GitCommandManager, settings: GitSourceSettings) {
logger.info("Disabling automatic garbage collection")
git.tryDisableAutomaticGarbageCollection()

settings.ref = git.getDefaultBranch(git.workingDirectory)
logger.info("Determining default branch for repository: ${git.workingDirectory}, default branch: ${settings.ref}")
settings.ref = git.getDefaultBranch(settings.repository)
logger.info("Determining default branch for repository: ${settings.repository}, default branch: ${settings.ref}")

val refHelper = RefHelper()
val refSpec = refHelper.getRefSpecForAllHistory(settings.ref, settings.branch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GitCommandManager(var workingDirectory: String = ".", private var lfs: Boo
private val exec = Command()

fun init(): GitOutput {
return execGit(listOf("init", workingDirectory))
return execGit(listOf("init", "."))
}

fun remoteAdd(remoteName: String, remoteUrl: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class GitSourceSettings(
val serverSide: Boolean = false,
val submodule: Boolean = false,
var fetchDepth: Int = 0,
var workdir: String = "",
var workdir: String = ".tmp",
) : CommandSetting {
val gitServerUrl: String = "https://github.com"
val nestedSubmodules: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ class GitSourceSettingsTest {
val settings = GitSourceSettings(
repository = repository,
branch = branch,
workdir = ".tmp",
)

val commandManager = GitCommandManager(settings.repositoryPath)
doCheckout(commandManager, settings)
executeGitCheckout(settings)
}
}

0 comments on commit b9e0a59

Please sign in to comment.