Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ func runAgent(agentName, fullsendDir, outputBase, targetRepo, fullsendBinary str
printer.StepWarn("Could not upload .git directory: " + err.Error())
}
}
if err := sandbox.RestoreSymlinks(sandboxName, repoDir); err != nil {
printer.StepWarn("Could not restore symlinks: " + err.Error())
}
printer.StepDone(fmt.Sprintf("Project code copied to %s/ (%.1fs)", repoName, time.Since(copyStart).Seconds()))

// 8a. Inject org-level AGENTS.md if the target repo does not have one.
Expand Down
18 changes: 18 additions & 0 deletions internal/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,24 @@ func Upload(sandboxName, localPath, remotePath string) error {
return nil
}

// RestoreSymlinks recreates git-tracked symlinks after a sandbox upload.
// openshell sandbox upload dereferences symlinks into real directories;
// this reads the git index for mode-120000 entries and recreates them.
func RestoreSymlinks(sandboxName, repoDir string) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[info] test-coverage

RestoreSymlinks has no unit test. A table-driven test with a mock Exec could validate the shell command construction without requiring a live sandbox.

cmd := fmt.Sprintf(
`cd %s && git ls-files --stage | awk '$1=="120000"{print $2,$4}' | while IFS=' ' read sha path; do target=$(git cat-file blob "$sha"); rm -rf "$path"; mkdir -p "$(dirname "$path")"; ln -s "$target" "$path"; done`,
repoDir,
Comment thread
rh-hemartin marked this conversation as resolved.
Resolved
)
_, stderr, exitCode, err := Exec(sandboxName, cmd, 30*time.Second)
if err != nil {
return fmt.Errorf("restoring symlinks in sandbox %q: %w", sandboxName, err)
}
if exitCode != 0 {
return fmt.Errorf("restoring symlinks in sandbox %q: exit %d: %s", sandboxName, exitCode, stderr)
}
return nil
}

// Download copies a file or directory from a sandbox to the local machine.
// The localPath is always treated as a directory by openshell — for single-file
// downloads use DownloadFile instead.
Expand Down
Loading