@@ -123,6 +123,8 @@ type CloneRepoOptions struct {
123123 Depth int
124124 Filter string
125125 SkipTLSVerify bool
126+ SingleBranch bool
127+ Env []string
126128}
127129
128130// Clone clones original repository to target path.
@@ -157,6 +159,9 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error {
157159 if opts .Filter != "" {
158160 cmd .AddArguments ("--filter" ).AddDynamicArguments (opts .Filter )
159161 }
162+ if opts .SingleBranch {
163+ cmd .AddArguments ("--single-branch" )
164+ }
160165 if len (opts .Branch ) > 0 {
161166 cmd .AddArguments ("-b" ).AddDynamicArguments (opts .Branch )
162167 }
@@ -167,13 +172,17 @@ func Clone(ctx context.Context, from, to string, opts CloneRepoOptions) error {
167172 }
168173
169174 envs := os .Environ ()
170- u , err := url .Parse (from )
171- if err == nil {
172- envs = proxy .EnvWithProxy (u )
175+ if opts .Env != nil {
176+ envs = opts .Env
177+ } else {
178+ u , err := url .Parse (from )
179+ if err == nil {
180+ envs = proxy .EnvWithProxy (u )
181+ }
173182 }
174183
175184 stderr := new (bytes.Buffer )
176- if err = cmd .
185+ if err : = cmd .
177186 WithTimeout (opts .Timeout ).
178187 WithEnv (envs ).
179188 WithStdout (io .Discard ).
@@ -228,14 +237,3 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error {
228237
229238 return nil
230239}
231-
232- // GetLatestCommitTime returns time for latest commit in repository (across all branches)
233- func GetLatestCommitTime (ctx context.Context , repoPath string ) (time.Time , error ) {
234- cmd := gitcmd .NewCommand ("for-each-ref" , "--sort=-committerdate" , BranchPrefix , "--count" , "1" , "--format=%(committerdate)" )
235- stdout , _ , err := cmd .WithDir (repoPath ).RunStdString (ctx )
236- if err != nil {
237- return time.Time {}, err
238- }
239- commitTime := strings .TrimSpace (stdout )
240- return time .Parse ("Mon Jan _2 15:04:05 2006 -0700" , commitTime )
241- }
0 commit comments