Exemple #1
0
 private void ShowGitAccessorSetupControl(IGitAccessorProvider accessorProvider, IGitAccessor accessor)
 {
     if (accessorProvider != null)
     {
         var type = accessorProvider.GetType();
         Tuple <IGitAccessor, DialogBase> cachedControl;
         if (_cachedControls.TryGetValue(type, out cachedControl))
         {
             ShowGitAccessorSetupControl(cachedControl.Item2);
             _selectedAccessorProvder = accessorProvider;
             _selectedAccessor        = cachedControl.Item1;
         }
         else
         {
             if (accessor == null)
             {
                 accessor = accessorProvider.CreateAccessor();
             }
             Func <IGitAccessor, DialogBase> setupControlFactory;
             if (_gitAcessorSetupControls.TryGetValue(type, out setupControlFactory))
             {
                 var setupControl = setupControlFactory(accessor);
                 ShowGitAccessorSetupControl(setupControl);
                 _cachedControls.Add(type, Tuple.Create(accessor, setupControl));
             }
             _selectedAccessorProvder = accessorProvider;
             _selectedAccessor        = accessor;
         }
     }
 }
Exemple #2
0
        public static void Init(IGitAccessor gitAccessor, string path, bool bare)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNeitherNullNorWhitespace(path, "path");

            gitAccessor.InitRepository.Invoke(new InitRepositoryParameters(path, null, bare));
        }
Exemple #3
0
        public static Task <Repository> LoadAsync(IGitAccessor gitAccessor, string workingDirectory, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));
            Verify.Argument.IsNotNull(workingDirectory, nameof(workingDirectory));

            return(Task.Factory.StartNew(
                       () =>
            {
                progress?.Report(new OperationProgress(Resources.StrLoadingRepository.AddEllipsis()));
                var repository = new Repository(gitAccessor, workingDirectory, false);
                try
                {
                    LoadCore(repository, progress, cancellationToken);
                }
                catch
                {
                    repository.Dispose();
                    throw;
                }
                return repository;
            },
                       cancellationToken,
                       TaskCreationOptions.None,
                       TaskScheduler.Default));
        }
Exemple #4
0
        /// <summary>Create <see cref="Repository"/>.</summary>
        /// <param name="gitAccessor">Git repository access provider.</param>
        /// <param name="workingDirectory">Repository working directory.</param>
        /// <param name="load"><c>true</c> to load repository; <c>false</c> otherwise.</param>
        private Repository(IGitAccessor gitAccessor, string workingDirectory, bool load)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));
            Verify.Argument.IsNotNull(workingDirectory, nameof(workingDirectory));

            _workingDirectory     = GetWorkingDirectory(workingDirectory);
            _gitDirectory         = GetGitDirectory(_workingDirectory);
            _configurationManager = GetConfigurationManager(_gitDirectory);

            _accessor      = gitAccessor.CreateRepositoryAccessor(this);
            _revisionCache = new RevisionCache(this);
            _configuration = new ConfigParametersCollection(this);
            _status        = new Status(this);
            _stash         = new StashedStatesCollection(this);
            _refs          = new RefsCollection(this);
            _notes         = new NotesCollection(this);
            _remotes       = new RemotesCollection(this);
            _submodules    = new SubmodulesCollection(this);
            _users         = new UsersCollection(this);
            _hooks         = new HooksCollection(this);

            if (load)
            {
                try
                {
                    LoadCore(this, null, CancellationToken.None);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
        }
Exemple #5
0
        public static Task CloneAsync(
            IGitAccessor gitAccessor,
            string url, string path, string template, string remoteName,
            bool shallow, int depth, bool bare, bool mirror, bool recursive, bool noCheckout,
            IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));

            return(gitAccessor.CloneRepository.InvokeAsync(
                       new CloneRepositoryParameters()
            {
                Url = url,
                Path = path,
                Template = template,
                RemoteName = remoteName,

                Shallow = shallow,
                Depth = depth,
                Bare = bare,
                Mirror = mirror,
                Recursive = recursive,
                NoCheckout = noCheckout,
            },
                       progress, cancellationToken));
        }
Exemple #6
0
        /// <summary>Create <see cref="Repository"/>.</summary>
        /// <param name="gitAccessor">Git repository access provider.</param>
        /// <param name="workingDirectory">Repository working directory.</param>
        /// <param name="load"><c>true</c> to load repository; <c>false</c> otherwise.</param>
        private Repository(IGitAccessor gitAccessor, string workingDirectory, bool load)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNotNull(workingDirectory, "workingDirectory");

            _workingDirectory     = GetWorkingDirectory(workingDirectory);
            _gitDirectory         = GetGitDirectory(_workingDirectory);
            _configurationManager = GetConfigurationManager(_gitDirectory);

            _accessor      = gitAccessor.CreateRepositoryAccessor(this);
            _revisionCache = new RevisionCache(this);
            _configuration = new ConfigParametersCollection(this);
            _status        = new Status(this);
            _stash         = new StashedStatesCollection(this);
            _refs          = new RefsCollection(this);
            _notes         = new NotesCollection(this);
            _remotes       = new RemotesCollection(this);
            _submodules    = new SubmodulesCollection(this);
            _users         = new UsersCollection(this);
            _hooks         = new HooksCollection(this);

            if(load)
            {
                try
                {
                    LoadCore(this, null, CancellationToken.None);
                }
                catch
                {
                    Dispose();
                    throw;
                }
            }
        }
Exemple #7
0
        public static void Init(IGitAccessor gitAccessor, string path)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));
            Verify.Argument.IsNeitherNullNorWhitespace(path, nameof(path));

            gitAccessor.InitRepository.Invoke(new InitRepositoryParameters(path, null, false));
        }
Exemple #8
0
        public CliOptionsPage(IGitAccessor gitAccessor)
            : base(Guid)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");

            _gitCLI = (GitCLI)gitAccessor;

            InitializeComponent();

            Text = Resources.StrCommandLineInterface;

            _lblPathToGitExe.Text = Resources.StrPathToGitExe.AddColon();
            _lblFoundVersion.Text = Resources.StrFoundVersion.AddColon();

            _radAlwaysAutodetect.Text = Resources.StrsAlwaysAutodetect;
            _radSpecifyManually.Text  = Resources.StrsSpecifyManually;

            _cmdAutoDetect.Text = Resources.StrAutodetect;
            _cmdBrowse.Text     = Resources.StrBrowse.AddEllipsis();

            _chkLogCLICalls.Text    = Resources.StrsLogCLICalls;
            _chkFallbackToAnsi.Text = Resources.StrsFallbackToAnsi + ' ' + Resources.StrlRestartRequired.SurroundWithBraces();

            _lblLatestVersionValue.Text   = Resources.StrsSearching.AddEllipsis();
            _lblLatestVersion.Text        = Resources.StrLatestVersion.AddColon();
            _btnDownload.Text             = Resources.StrInstall;
            _btnRefreshLatestVersion.Text = Resources.StrRefresh;

            if (_gitCLI.AutodetectGitExePath)
            {
                _radAlwaysAutodetect.Checked = true;
            }
            else
            {
                _radSpecifyManually.Checked = true;
            }
            _versionPath         = _gitCLI.GitExecutablePath;
            _txtmSysGitPath.Text = _versionPath;

            _chkLogCLICalls.Checked    = _gitCLI.LogCalls;
            _chkFallbackToAnsi.Checked = GitProcess.EnableAnsiCodepageFallback;

            var version = TryGetVersion();

            if (version != null)
            {
                _lblVersion.Text = version.ToString();
            }
            else
            {
                _lblVersion.Text = Resources.StrlUnavailable.SurroundWith("<", ">");
            }

            GitterApplication.FontManager.InputFont.Apply(_txtmSysGitPath);
        }
Exemple #9
0
 public static GuiCommandStatus Clone(IWin32Window parent, IGitAccessor gitAccessor, string url, string path, string template, string remoteName, bool shallow, int depth, bool bare, bool mirror, bool recursive, bool noCheckout)
 {
     try
     {
         ProgressForm.MonitorTaskAsModalWindow(parent, Resources.StrClone, (p, c) =>
                                               Repository.CloneAsync(gitAccessor, url, path, template, remoteName, shallow, depth, bare, mirror, recursive, noCheckout, p, c));
         return(GuiCommandStatus.Completed);
     }
     catch (OperationCanceledException)
     {
         return(GuiCommandStatus.Canceled);
     }
     catch (GitException exc)
     {
         GitterApplication.MessageBoxService.Show(
             parent,
             exc.Message,
             Resources.ErrFailedToClone.UseAsFormat(url),
             MessageBoxButton.Close,
             MessageBoxIcon.Error);
         return(GuiCommandStatus.Faulted);
     }
 }
Exemple #10
0
        public static void Clone(
            IGitAccessor gitAccessor,
            string url, string path, string template, string remoteName,
            bool shallow, int depth, bool bare, bool mirror, bool recursive, bool noCheckout)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));

            gitAccessor.CloneRepository.Invoke(
                new CloneRepositoryParameters()
            {
                Url        = url,
                Path       = path,
                Template   = template,
                RemoteName = remoteName,

                Shallow    = shallow,
                Depth      = depth,
                Bare       = bare,
                Mirror     = mirror,
                Recursive  = recursive,
                NoCheckout = noCheckout,
            });
        }
Exemple #11
0
 public static Repository Load(IGitAccessor gitAccessor, string workingDirectory)
 {
     return(new Repository(gitAccessor, workingDirectory, true));
 }
Exemple #12
0
 public abstract bool IsAvailableFor(IGitAccessor gitAccessor);
Exemple #13
0
        public static void Init(IGitAccessor gitAccessor, string path)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNeitherNullNorWhitespace(path, "path");

            gitAccessor.InitRepository.Invoke(new InitRepositoryParameters(path, null, false));
        }
Exemple #14
0
        public override bool IsAvailableFor(IGitAccessor gitAccessor)
        {
            Verify.Argument.IsNotNull(gitAccessor, nameof(gitAccessor));

            return(gitAccessor.GitVersion >= RequiredVersion);
        }
Exemple #15
0
 public abstract bool IsAvailableFor(IGitAccessor gitAccessor);
Exemple #16
0
        public static Task<Repository> LoadAsync(IGitAccessor gitAccessor, string workingDirectory, IProgress<OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");
            Verify.Argument.IsNotNull(workingDirectory, "workingDirectory");

            return Task.Factory.StartNew(
                () =>
                {
                    if(progress != null)
                    {
                        progress.Report(new OperationProgress(Resources.StrLoadingRepository.AddEllipsis()));
                    }
                    var repository = new Repository(gitAccessor, workingDirectory, false);
                    try
                    {
                        LoadCore(repository, progress, cancellationToken);
                    }
                    catch
                    {
                        repository.Dispose();
                        throw;
                    }
                    return repository;
                },
                cancellationToken,
                TaskCreationOptions.None,
                TaskScheduler.Default);
        }
Exemple #17
0
 public static Repository Load(IGitAccessor gitAccessor, string workingDirectory)
 {
     return new Repository(gitAccessor, workingDirectory, true);
 }
Exemple #18
0
        public static void Clone(
            IGitAccessor gitAccessor,
            string url, string path, string template, string remoteName,
            bool shallow, int depth, bool bare, bool mirror, bool recursive, bool noCheckout)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");

            gitAccessor.CloneRepository.Invoke(
                new CloneRepositoryParameters()
                {
                    Url = url,
                    Path = path,
                    Template = template,
                    RemoteName = remoteName,

                    Shallow = shallow,
                    Depth = depth,
                    Bare = bare,
                    Mirror = mirror,
                    Recursive = recursive,
                    NoCheckout = noCheckout,
                });
        }
Exemple #19
0
        public static Task CloneAsync(
            IGitAccessor gitAccessor,
            string url, string path, string template, string remoteName,
            bool shallow, int depth, bool bare, bool mirror, bool recursive, bool noCheckout,
            IProgress<OperationProgress> progress, CancellationToken cancellationToken)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");

            return gitAccessor.CloneRepository.InvokeAsync(
                new CloneRepositoryParameters()
                {
                    Url = url,
                    Path = path,
                    Template = template,
                    RemoteName = remoteName,

                    Shallow = shallow,
                    Depth = depth,
                    Bare = bare,
                    Mirror = mirror,
                    Recursive = recursive,
                    NoCheckout = noCheckout,
                },
                progress, cancellationToken);
        }
Exemple #20
0
        public override bool IsAvailableFor(IGitAccessor gitAccessor)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");

            return gitAccessor.GitVersion >= _version;
        }
Exemple #21
0
        public override bool IsAvailableFor(IGitAccessor gitAccessor)
        {
            Verify.Argument.IsNotNull(gitAccessor, "gitAccessor");

            return(gitAccessor.GitVersion >= _version);
        }