Skip to content

Commit

Permalink
Add some smart for hardlink to symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Dec 17, 2024
1 parent 5a0513b commit 8203a62
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
20 changes: 16 additions & 4 deletions sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,26 @@ func Make(ctx context.Context, cfg MakeConfig) error {
}
untarDedup.Add(to)

err := xfs.CreateParentDir(to)
err = xfs.CreateParentDir(to)
if err != nil {
return err
}

err = os.Link(file.From, to)
if err != nil {
return fmt.Errorf("make: link %v to %v: %w", file.From, to, err)
target, err := os.Readlink(file.From)
if err == nil {
if !filepath.IsAbs(target) {
target = filepath.Join(filepath.Dir(file.From), target)
}

err = os.Symlink(target, to)
if err != nil {
return err
}
} else {
err = os.Link(file.From, to)
if err != nil {
return fmt.Errorf("make: link %v to %v: %w", file.From, to, err)
}
}

if cfg.ProgressLinks != nil {
Expand Down
6 changes: 6 additions & 0 deletions utils/xstarlark/fmt/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ func (f *formatter) formatStmt(w Writer, sstmt syntax.Stmt) error {
return err
}
case *syntax.ReturnStmt:
if stmt.Result == nil {
w.WriteString("return")

return nil
}

w.WriteString("return ")
return f.formatExpr(w, stmt.Result)
case *IfStmt:
Expand Down

0 comments on commit 8203a62

Please sign in to comment.