private static void ShutdownGit(GitRepositoryFolder repositoryFolder)
		{
            string path = repositoryFolder.GetAbsolutePath();
			var git = NGit.Api.Git.Open(path);
			git.GetRepository().Close();
			WindowCache.Reconfigure(new WindowCacheConfig());
		}
Exemple #2
0
        private static void ShutdownGit(GitRepositoryFolder repositoryFolder)
        {
            string path = repositoryFolder.GetAbsolutePath();
            var    git  = NGit.Api.Git.Open(path);

            git.GetRepository().Close();
            WindowCache.Reconfigure(new WindowCacheConfig());
        }
		public static GitRepositoryFolder Create(string repoUri)
		{
            GitRepositoryFolder folder = new GitRepositoryFolder();
            folder.RepoUri = repoUri;

            // form relative path to local repository
            Uri absoluteUri = new Uri(Path.Combine(GitCloneRootFolder, Guid.NewGuid().ToString()));
            Uri baseUri = new Uri(AppDomain.CurrentDomain.BaseDirectory);
            Uri relativeUri = baseUri.MakeRelativeUri(absoluteUri);
            folder.Value = relativeUri.OriginalString;

            return folder;
		}
Exemple #4
0
        public static GitRepositoryFolder Create(string repoUri)
        {
            GitRepositoryFolder folder = new GitRepositoryFolder();

            folder.RepoUri = repoUri;

            // form relative path to local repository
            Uri absoluteUri = new Uri(Path.Combine(GitCloneRootFolder, Guid.NewGuid().ToString()));
            Uri baseUri     = new Uri(AppDomain.CurrentDomain.BaseDirectory);
            Uri relativeUri = baseUri.MakeRelativeUri(absoluteUri);

            folder.Value = relativeUri.OriginalString;

            return(folder);
        }
        private NGit.Api.Git GetClient(ISourceControlConnectionSettingsSource settings)
        {
            var repositoryFolder = GetLocalRepository(settings);

            if (IsRepositoryUriChanged(repositoryFolder, settings))
            {
                repositoryFolder.Delete();
                repositoryFolder = GitRepositoryFolder.Create(settings.Uri);
                _folder.ReplaceWith(repositoryFolder);
            }

            NGit.Api.Git nativeGit;

            try
            {
                var credentialsProvider = new UsernamePasswordCredentialsProvider(settings.Login, settings.Password);
                if (repositoryFolder.Exists())
                {
                    string path = repositoryFolder.GetAbsolutePath();
                    nativeGit = NGit.Api.Git.Open(path);
                }
                else
                {
                    string path = repositoryFolder.GetAbsolutePath();
                    nativeGit = NGit.Api.Git.CloneRepository()
                                .SetURI(settings.Uri)
                                .SetNoCheckout(true)
                                .SetCredentialsProvider(credentialsProvider)
                                .SetDirectory(path).Call();
                }
            }
            catch (EOFException ex)
            {
                throw new InvalidOperationException("Unable to connect to repository. Run 'git fsck' in the repository to check for possible errors.", ex);
            }
            catch (ArgumentNullException exception)
            {
                throw new ArgumentException(
                          GitCheckConnectionErrorResolver.INVALID_URI_OR_INSUFFICIENT_ACCESS_RIGHTS_ERROR_MESSAGE, exception);
            }

            return(nativeGit);
        }
        private GitRepositoryFolder GetLocalRepository(ISourceControlConnectionSettingsSource settings)
        {
            if (_folder.Empty())
            {
                var repositoryFolder = GitRepositoryFolder.Create(settings.Uri);
                _folder.ReplaceWith(repositoryFolder);
                return(repositoryFolder);
            }

            GitRepositoryFolder folder = _folder.Single();

            if (!folder.CheckFolder(_folder))
            {
                var repositoryFolder = GitRepositoryFolder.Create(settings.Uri);
                _folder.ReplaceWith(repositoryFolder);
                return(repositoryFolder);
            }

            return(folder);
        }
 private static bool IsRepositoryUriChanged(GitRepositoryFolder repositoryFolder,
                                            ISourceControlConnectionSettingsSource settings)
 {
     return((settings.Uri.ToLower() != repositoryFolder.RepoUri.ToLower()) && repositoryFolder.Exists());
 }
		private static bool IsRepositoryUriChanged(GitRepositoryFolder repositoryFolder,
		                                           ISourceControlConnectionSettingsSource settings)
		{
			return (settings.Uri.ToLower() != repositoryFolder.RepoUri.ToLower()) && repositoryFolder.Exists();
		}
 private static void ShutdownGit(GitRepositoryFolder repositoryFolder)
 {
     var git = NGit.Api.Git.Open(repositoryFolder.Value);
     git.GetRepository().Close();
     WindowCache.Reconfigure(new WindowCacheConfig());
 }