From ab78b2b49d6def897b913c92bcce5546b1025f3a Mon Sep 17 00:00:00 2001 From: Ghais Zaher Date: Tue, 17 Oct 2023 09:49:41 +0200 Subject: [PATCH] move TryLock up --- server/events/project_command_builder.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/events/project_command_builder.go b/server/events/project_command_builder.go index 6eedd8b24e..2fc3a647ab 100644 --- a/server/events/project_command_builder.go +++ b/server/events/project_command_builder.go @@ -509,8 +509,15 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *command.Cont var pcc []command.ProjectContext + ctx.Log.Debug("building plan command") + unlockFn, err := p.WorkingDirLocker.TryLock(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num, workspace, DefaultRepoRelDir) + if err != nil { + return pcc, err + } + defer unlockFn() + ctx.Log.Debug("cloning repository") - _, _, err := p.WorkingDir.Clone(ctx.HeadRepo, ctx.Pull, workspace) + _, _, err = p.WorkingDir.Clone(ctx.HeadRepo, ctx.Pull, workspace) if err != nil { return pcc, err } @@ -586,13 +593,6 @@ func (p *DefaultProjectCommandBuilder) buildProjectPlanCommand(ctx *command.Cont } } - ctx.Log.Debug("building plan command") - unlockFn, err := p.WorkingDirLocker.TryLock(ctx.Pull.BaseRepo.FullName, ctx.Pull.Num, workspace, DefaultRepoRelDir) - if err != nil { - return pcc, err - } - defer unlockFn() - repoRelDir := DefaultRepoRelDir if cmd.RepoRelDir != "" { repoRelDir = cmd.RepoRelDir