Skip to content

Commit

Permalink
fix: fix working dir error issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 8, 2023
1 parent 76cede1 commit 4197a84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ import org.archguard.action.io.FileExt
import java.io.File

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

doCheckout(git, settings)
}

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

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

FileExt.mkdir(settings.repositoryPath)
FileExt.mkdir(git.workingDirectory)

authHelper.configureTempGlobalConfig()

git.config("safe.directory", settings.repositoryPath, true, true)
git.config("safe.directory", git.workingDirectory, true, true)

logger.info("Initializing git repository")
git.init()
Expand All @@ -36,8 +36,8 @@ fun doCheckout(git: GitCommandManager, settings: GitSourceSettings) {
logger.info("Disabling automatic garbage collection")
git.tryDisableAutomaticGarbageCollection()

settings.ref = git.getDefaultBranch(settings.repository)
logger.info("Determining default branch for repository: ${settings.repository}, default branch: ${settings.ref}")
settings.ref = git.getDefaultBranch(git.workingDirectory)
logger.info("Determining default branch for repository: ${git.workingDirectory}, 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 @@ -35,7 +35,7 @@ class GitSourceSettings(
sshKey = argsMap["--ssh-key"] ?: "",
serverSide = argsMap["--server-side"]?.toBoolean() ?: false,
submodule = argsMap["--submodule"]?.toBoolean() ?: false,
workdir = argsMap["--workdir"] ?: ".",
workdir = argsMap["--workdir"] ?: ".tmp",
)
}
}
Expand Down

0 comments on commit 4197a84

Please sign in to comment.