AsposeVisualStudioPluginPdf.Core.GitHelper.CloneOrCheckOutRepo C# (CSharp) Method

CloneOrCheckOutRepo() public static method

public static CloneOrCheckOutRepo ( AsposeComponent component ) : string
component AsposeComponent
return string
        public static string CloneOrCheckOutRepo(AsposeComponent component)
        {
            if (Directory.Exists(getLocalRepositoryPath(component)))
            {
                if (Directory.Exists(getLocalRepositoryPath(component) + "\\.git\\refs\\heads"))
                {
                    if (Directory.GetFiles(getLocalRepositoryPath(component) + "\\.git\\refs\\heads").Length <= 0)
                    {
                        System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(getLocalRepositoryPath(component));
                        Empty(directory);
                    }
                }
            }

            string repUrl = component.get_remoteExamplesRepository();
            string localFolder = getLocalRepositoryPath(component);
            string error = string.Empty;

            checkAndCreateFolder(getLocalRepositoryPath(component));

            try
            {
                CloneCommand clone = Git.CloneRepository();
                clone.SetURI(repUrl);
                clone.SetDirectory(localFolder);

                Git repo = clone.Call();
                //writer.Close();
                repo.GetRepository().Close();
            }
            catch (Exception ex)
            {
                try
                {
                    var git = Git.Open(localFolder);
                    //var repository = git.GetRepository();
                    //PullCommand pullCommand = git.Pull();
                    //pullCommand.Call();
                    //repository.Close();

                    var reset = git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef("origin/master").Call();

                }
                catch (Exception ex2)
                {

                    error = ex2.Message;
                }

                error = ex.Message;
            }

            return error;
        }