@@ -772,46 +772,38 @@ public static string Clone(string sourceUrl, string workdirPath)
772
772
/// <param name="workdirPath">Local path to clone into</param>
773
773
/// <param name="options"><see cref="CloneOptions"/> controlling clone behavior</param>
774
774
/// <returns>The path to the created repository.</returns>
775
- public static string Clone ( string sourceUrl , string workdirPath ,
776
- CloneOptions options )
775
+ public static string Clone ( string sourceUrl , string workdirPath , CloneOptions options )
777
776
{
778
777
Ensure . ArgumentNotNull ( sourceUrl , "sourceUrl" ) ;
779
778
Ensure . ArgumentNotNull ( workdirPath , "workdirPath" ) ;
780
779
781
780
options ??= new CloneOptions ( ) ;
782
781
783
- // As default behaviour for GitFetchOptionsWrapper ctor is to create
784
- // a new instance of GitFetchOptions we only populate the Depth field.
785
- var fetchOptions = new GitFetchOptions
786
- {
787
- Depth = options . FetchOptions . Depth ,
788
- } ;
789
-
790
782
// context variable that contains information on the repository that
791
783
// we are cloning.
792
784
var context = new RepositoryOperationContext ( Path . GetFullPath ( workdirPath ) , sourceUrl ) ;
793
785
794
786
// Notify caller that we are starting to work with the current repository.
795
- bool continueOperation = OnRepositoryOperationStarting ( options . FetchOptions . RepositoryOperationStarting ,
796
- context ) ;
787
+ bool continueOperation = OnRepositoryOperationStarting ( options . FetchOptions . RepositoryOperationStarting , context ) ;
797
788
798
789
if ( ! continueOperation )
799
790
{
800
791
throw new UserCancelledException ( "Clone cancelled by the user." ) ;
801
792
}
802
793
803
794
using ( var checkoutOptionsWrapper = new GitCheckoutOptsWrapper ( options ) )
804
- using ( var fetchOptionsWrapper = new GitFetchOptionsWrapper ( fetchOptions ) )
795
+ using ( var fetchOptionsWrapper = new GitFetchOptionsWrapper ( ) )
805
796
{
806
797
var gitCheckoutOptions = checkoutOptionsWrapper . Options ;
807
798
808
799
var gitFetchOptions = fetchOptionsWrapper . Options ;
800
+ gitFetchOptions . Depth = options . FetchOptions . Depth ;
809
801
gitFetchOptions . ProxyOptions = options . FetchOptions . ProxyOptions . CreateGitProxyOptions ( ) ;
810
802
gitFetchOptions . RemoteCallbacks = new RemoteCallbacks ( options . FetchOptions ) . GenerateCallbacks ( ) ;
803
+
811
804
if ( options . FetchOptions != null && options . FetchOptions . CustomHeaders != null )
812
805
{
813
- gitFetchOptions . CustomHeaders =
814
- GitStrArrayManaged . BuildFrom ( options . FetchOptions . CustomHeaders ) ;
806
+ gitFetchOptions . CustomHeaders = GitStrArrayManaged . BuildFrom ( options . FetchOptions . CustomHeaders ) ;
815
807
}
816
808
817
809
var cloneOpts = new GitCloneOptions
@@ -839,8 +831,7 @@ public static string Clone(string sourceUrl, string workdirPath,
839
831
}
840
832
841
833
// Notify caller that we are done with the current repository.
842
- OnRepositoryOperationCompleted ( options . FetchOptions . RepositoryOperationCompleted ,
843
- context ) ;
834
+ OnRepositoryOperationCompleted ( options . FetchOptions . RepositoryOperationCompleted , context ) ;
844
835
845
836
// Recursively clone submodules if requested.
846
837
try
@@ -849,9 +840,7 @@ public static string Clone(string sourceUrl, string workdirPath,
849
840
}
850
841
catch ( Exception ex )
851
842
{
852
- throw new RecurseSubmodulesException ( "The top level repository was cloned, but there was an error cloning its submodules." ,
853
- ex ,
854
- clonedRepoPath ) ;
843
+ throw new RecurseSubmodulesException ( "The top level repository was cloned, but there was an error cloning its submodules." , ex , clonedRepoPath ) ;
855
844
}
856
845
857
846
return clonedRepoPath ;
0 commit comments