Skip to content

Commit cb0198a

Browse files
authored
feat: support added for submodule clone and use depth 1 (#291) (#292)
1 parent f99c594 commit cb0198a

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

git_manager/repo.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ func FetchLatestCommitHash(git_url string, branch string, username string, passw
2525
}
2626
// clone the repo
2727
r, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
28-
URL: git_url,
29-
SingleBranch: true,
30-
Progress: nil,
31-
ReferenceName: plumbing.NewBranchReferenceName(branch),
32-
Auth: httpAuth,
28+
URL: git_url,
29+
SingleBranch: true,
30+
Progress: nil,
31+
ReferenceName: plumbing.NewBranchReferenceName(branch),
32+
Auth: httpAuth,
33+
Depth: 1,
34+
RecurseSubmodules: git.NoRecurseSubmodules, // No submodules for fetch commit hash
35+
ShallowSubmodules: true,
3336
})
3437
if err != nil {
3538
return "", errors.New("failed to clone repository")
@@ -61,10 +64,13 @@ func CloneRepository(git_url string, branch string, username string, password st
6164
}
6265
// clone the repo
6366
_, err := git.PlainClone(dest_folder, false, &git.CloneOptions{
64-
URL: git_url,
65-
Progress: nil,
66-
ReferenceName: plumbing.NewBranchReferenceName(branch),
67-
Auth: httpAuth,
67+
URL: git_url,
68+
Progress: nil,
69+
ReferenceName: plumbing.NewBranchReferenceName(branch),
70+
Auth: httpAuth,
71+
Depth: 1,
72+
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
73+
ShallowSubmodules: true,
6874
})
6975
if err != nil {
7076
log.Println(err)

0 commit comments

Comments
 (0)