Skip to content

Commit bd183fa

Browse files
feat(devpod): add skip git lfs for workspace repository to environment template
1 parent ff5393d commit bd183fa

File tree

8 files changed

+32
-10
lines changed

8 files changed

+32
-10
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ require (
3030
github.com/gorilla/websocket v1.5.3
3131
github.com/joho/godotenv v1.5.1
3232
github.com/julienschmidt/httprouter v1.3.0
33-
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29
33+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.31
3434
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e
35-
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29
35+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.31
3636
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459
3737
github.com/loft-sh/log v0.0.0-20250409101748-50124f882858
3838
github.com/loft-sh/programming-language-detection v0.0.5

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,14 @@ github.com/loft-sh/admin-apis v0.0.0-20250221182517-7499d86167d2 h1:om1MqUdW84ZQ
424424
github.com/loft-sh/admin-apis v0.0.0-20250221182517-7499d86167d2/go.mod h1:WHCqWfljfD1hkwk41hLeqBhW2yeLvWipB1sH6vfnR7U=
425425
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29 h1:AAbhuBMm6ZV3OXSx8VXqCqQ9o/mOl6Hh425qZsGNUqw=
426426
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29/go.mod h1:zkceRmB+KkkhDMHUQO1sQdcNfF2EPxl+RsSIEOAN/R8=
427+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.31 h1://tt9YAWfcCydJ5d991rsYin+KxzqNC3U6S8mEN882o=
428+
github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.31/go.mod h1:zkceRmB+KkkhDMHUQO1sQdcNfF2EPxl+RsSIEOAN/R8=
427429
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e h1:JcPnMaoczikvpasi8OJ47dCkWZjfgFubWa4V2SZo7h0=
428430
github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e/go.mod h1:FFWcGASyM2QlWTDTCG/WBVM/XYr8btqYt335TFNRCFg=
429431
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29 h1:0xlQGAMwluhI6UbiDarKT21v5j/AULpxpDADdPzDxxI=
430432
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29/go.mod h1:X1ho9aS6qCBMSOtIvRfjVa5htDO5UDlYyDUAKpvtY+k=
433+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.31 h1:H2k4Qi7zWloBQmD6fepUaZOpzmv6A7WxAWtDOdzrQC0=
434+
github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.31/go.mod h1:qBNf6+sIg2XNYdBWe2c16C1gjDcrKZ88sGd76oYT3Jg=
431435
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459 h1:6SrgBtT1S9ANsQMoO/O0Mq+hs9EbC5te5kPqOBfg5UI=
432436
github.com/loft-sh/apiserver v0.0.0-20250206205835-422f1d472459/go.mod h1:rung3jsKjaVAtykQN0vWmFHhx2A/umpRyAae8BJVSeE=
433437
github.com/loft-sh/log v0.0.0-20250409101748-50124f882858 h1:MKlp3CvzXqd+a2plptpE/bKcVMb8t/7BrEuy6Yqmnaw=

pkg/agent/workspace.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,10 @@ func CloneRepositoryForWorkspace(
374374
}
375375
} else {
376376
if options.Platform.GitCloneStrategy != "" {
377-
log.Info("Using a %s clone", options.Platform.GitCloneStrategy)
377+
log.Infof("Using a %s clone", options.Platform.GitCloneStrategy)
378+
}
379+
if options.Platform.GitSkipLFS {
380+
log.Info("Skipping Git LFS")
378381
}
379382
err := git.CloneRepositoryWithEnv(ctx, gitInfo, extraEnv, workspaceDir, helper, options.StrictHostKeyChecking, log, getGitOptions(options)...)
380383
if err != nil {
@@ -415,6 +418,9 @@ func getGitOptions(options provider2.CLIOptions) []git.Option {
415418
if options.Platform.GitCloneStrategy != "" {
416419
gitOpts = append(gitOpts, git.WithCloneStrategy(git.CloneStrategy(options.Platform.GitCloneStrategy)))
417420
}
421+
if options.Platform.GitSkipLFS {
422+
gitOpts = append(gitOpts, git.WithSkipLFS())
423+
}
418424
if options.GitCloneRecursiveSubmodules {
419425
gitOpts = append(gitOpts, git.WithRecursiveSubmodules())
420426
}

pkg/git/clone.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ func WithRecursiveSubmodules() Option {
4040
}
4141
}
4242

43+
func WithSkipLFS() Option {
44+
return func(c *cloner) {
45+
c.skipLFS = true
46+
}
47+
}
48+
4349
func NewClonerWithOpts(options ...Option) Cloner {
4450
cloner := &cloner{
4551
cloneStrategy: FullCloneStrategy,
@@ -83,6 +89,7 @@ func (s *CloneStrategy) String() string {
8389
type cloner struct {
8490
extraArgs []string
8591
cloneStrategy CloneStrategy
92+
skipLFS bool
8693
}
8794

8895
var _ Cloner = &cloner{}
@@ -117,12 +124,12 @@ func (c *cloner) Clone(ctx context.Context, repository string, targetDir string,
117124
args = append(args, extraArgs...)
118125
args = append(args, c.extraArgs...)
119126
args = append(args, repository, targetDir)
120-
return run(ctx, args, extraEnv, log)
121-
}
122-
123-
func run(ctx context.Context, args []string, extraEnv []string, log log.Logger) error {
124127
args = append(args, "--progress")
125128

129+
if c.skipLFS {
130+
extraEnv = append(extraEnv, "GIT_LFS_SKIP_SMUDGE=1")
131+
}
132+
126133
w := &progressWriter{log: log, level: logrus.InfoLevel}
127134
gitCommand := CommandContext(ctx, extraEnv, args...)
128135
gitCommand.Stdout = w

vendor/github.com/loft-sh/api/v4/pkg/apis/management/zz_generated.api.register.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/apis/storage/v1/devpodenvironmenttemplate_types.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/loft-sh/api/v4/pkg/devpod/platformoptions.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,15 @@ github.com/liggitt/tabwriter
770770
# github.com/loft-sh/admin-apis v0.0.0-20250221182517-7499d86167d2
771771
## explicit; go 1.21.1
772772
github.com/loft-sh/admin-apis/pkg/licenseapi
773-
# github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.29
773+
# github.com/loft-sh/agentapi/v4 v4.3.0-devpod.alpha.31
774774
## explicit; go 1.23.1
775775
github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster
776776
github.com/loft-sh/agentapi/v4/pkg/apis/loft/cluster/v1
777777
github.com/loft-sh/agentapi/v4/pkg/apis/loft/storage/v1
778778
# github.com/loft-sh/analytics-client v0.0.0-20240219162240-2f4c64b2494e
779779
## explicit; go 1.21
780780
github.com/loft-sh/analytics-client/client
781-
# github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.29
781+
# github.com/loft-sh/api/v4 v4.3.0-devpod.alpha.31
782782
## explicit; go 1.23.1
783783
github.com/loft-sh/api/v4/pkg/apis/audit/v1
784784
github.com/loft-sh/api/v4/pkg/apis/management

0 commit comments

Comments
 (0)