/// <summary>
        /// 
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>

        public static string CloneOrCheckOutRepo(GroupDocsComponent component)
        {
            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;
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="component"></param>
        /// <returns></returns>

        public static string CloneOrCheckOutRepo(GroupDocsComponent component)
        {
            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);
        }
        private void checkAndUpdateRepo(GroupDocsComponent component)
        {
            if (null == component)
                return;
            if (null == component.get_remoteExamplesRepository() || component.RemoteExamplesRepository == string.Empty)
            {
                showMessage("Examples not available", component.get_name() + " - " + Constants.EXAMPLES_NOT_AVAILABLE_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
                examplesNotAvailable = true;
                return;
            }
            else
            {
                examplesNotAvailable = false;
            }

            if (GroupDocsComponentsManager.isIneternetConnected())
            {
                CloneOrCheckOutRepo(component);
            }
            else
            {
                showMessage(Constants.INTERNET_CONNECTION_REQUIRED_MESSAGE_TITLE, component.get_name() + " - " + Constants.EXAMPLES_INTERNET_CONNECTION_REQUIRED_MESSAGE, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }