This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 2280080d3 fixing running git clone multiple times (#8378)
2280080d3 is described below
commit 2280080d393bbdd3e87e91f7c59cceb92c4c19d4
Author: himanshu-garg-zepto <[email protected]>
AuthorDate: Mon Apr 21 15:00:00 2025 +0530
fixing running git clone multiple times (#8378)
* fixing running git clone multiple times
* fixes the missing os import
---------
Co-authored-by: Klesh Wong <[email protected]>
---
backend/plugins/dbt/tasks/git.go | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/backend/plugins/dbt/tasks/git.go b/backend/plugins/dbt/tasks/git.go
index d485857d9..49ea81f90 100644
--- a/backend/plugins/dbt/tasks/git.go
+++ b/backend/plugins/dbt/tasks/git.go
@@ -18,9 +18,11 @@ limitations under the License.
package tasks
import (
+ "os"
+ "os/exec"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
- "os/exec"
)
func Git(taskCtx plugin.SubTaskContext) errors.Error {
@@ -29,7 +31,16 @@ func Git(taskCtx plugin.SubTaskContext) errors.Error {
if data.Options.ProjectGitURL == "" {
return nil
}
- cmd := exec.Command("git", "clone", data.Options.ProjectGitURL)
+
+ // clean ProjectPath
+ err := os.RemoveAll(data.Options.ProjectPath)
+ if err != nil {
+ logger.Error(err, "cleanup before clone dbt project failed")
+ return errors.Convert(err)
+ }
+
+ // git clone from ProjectGitURL into ProjectPath
+ cmd := exec.Command("git", "clone", data.Options.ProjectGitURL,
data.Options.ProjectPath)
logger.Info("start clone dbt project: %v", cmd)
out, err := cmd.CombinedOutput()
if err != nil {