Exemplo n.º 1
0
        private void RecreateObservable()
        {
            CancelBackgroundOperation();

            int fetchInterval = FetchInterval.ValueOrDefault(Settings);

            var gitModule = currentGitUiCommands.GitModule;

            if (fetchInterval > 0 && gitModule.IsValidGitWorkingDir())
            {
                cancellationToken =
                    Observable.Timer(TimeSpan.FromSeconds(Math.Max(5, fetchInterval)))
                    .SelectMany(i =>
                {
                    // if git not runing - start fetch immediately
                    if (!gitModule.IsRunningGitProcess())
                    {
                        return(Observable.Return(i));
                    }

                    // in other case - every 5 seconds check if git still runnnig
                    return(Observable
                           .Interval(TimeSpan.FromSeconds(5))
                           .SkipWhile(ii => gitModule.IsRunningGitProcess())
                           .FirstAsync()
                           );
                })
                    .Repeat()
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(i =>
                {
                    if (FetchAllSubmodules.ValueOrDefault(Settings))
                    {
                        currentGitUiCommands.GitCommand("submodule foreach --recursive git fetch --all");
                    }

                    var gitCmd = GitCommand.ValueOrDefault(Settings).Trim();
                    var msg    = currentGitUiCommands.GitCommand(gitCmd);
                    if (AutoRefresh.ValueOrDefault(Settings))
                    {
                        if (gitCmd.StartsWith("fetch", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (msg.Contains("From"))
                            {
                                currentGitUiCommands.RepoChangedNotifier.Notify();
                            }
                        }
                        else
                        {
                            currentGitUiCommands.RepoChangedNotifier.Notify();
                        }
                    }
                });
            }
        }
 private static IEnumerable<string> GetTfsRemotes(IGitUICommands commands)
 {
     var result = commands.GitCommand("config --get-regexp tfs-remote");
     var matches = Regex.Matches(result, @"tfs-remote\.([^\.]+)");
     return matches.Count > 0
                ? matches.Cast<Match>().Select(g => g.Groups[1].Value).Distinct()
                : Enumerable.Empty<string>();
 }
 private static IEnumerable<string> GetTfsRemotes(IGitUICommands commands)
 {
     var result = commands.GitCommand("config --get-regexp tfs-remote");
     var match = Regex.Match(result, @"tfs-remote\.([^\.]+)");
     return match.Success
                ? match.Groups.Cast<Group>().Skip(1).Select(g => g.Value)
                : Enumerable.Empty<string>();
 }
Exemplo n.º 4
0
        private static IEnumerable <string> GetTfsRemotes(IGitUICommands commands)
        {
            var result = commands.GitCommand("config --get-regexp tfs-remote");
            var match  = Regex.Match(result, @"tfs-remote\.([^\.]+)");

            return(match.Success
                       ? match.Groups.Cast <Group>().Skip(1).Select(g => g.Value)
                       : Enumerable.Empty <string>());
        }
        private static IEnumerable <string> GetTfsRemotes(IGitUICommands commands)
        {
            var result  = commands.GitCommand("config --get-regexp tfs-remote");
            var matches = Regex.Matches(result, @"tfs-remote\.([^\.]+)");

            return(matches.Count > 0
                       ? matches.Cast <Match>().Select(g => g.Groups[1].Value).Distinct()
                       : Enumerable.Empty <string>());
        }
Exemplo n.º 6
0
        private void RecreateObservable()
        {
            CancelBackgroundOperation();

            int fetchInterval = FetchInterval[Settings];

            var gitModule = currentGitUiCommands.GitModule;

            if (fetchInterval > 0 && gitModule.IsValidGitWorkingDir())
            {
                cancellationToken =
                    Observable.Timer(TimeSpan.FromSeconds(Math.Max(5, fetchInterval)))
                    .SkipWhile(i => gitModule.IsRunningGitProcess())
                    .Repeat()
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(i =>
                {
                    if (FetchAllSubmodules[Settings].HasValue && FetchAllSubmodules[Settings].Value)
                    {
                        currentGitUiCommands.GitCommand("submodule foreach --recursive git fetch --all");
                    }

                    var gitCmd = GitCommand[Settings].Trim();
                    var msg    = currentGitUiCommands.GitCommand(gitCmd);
                    if (AutoRefresh[Settings].HasValue && AutoRefresh[Settings].Value)
                    {
                        if (gitCmd.StartsWith("fetch", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (msg.Contains("From"))
                            {
                                currentGitUiCommands.RepoChangedNotifier.Notify();
                            }
                        }
                        else
                        {
                            currentGitUiCommands.RepoChangedNotifier.Notify();
                        }
                    }
                }
                               );
            }
        }
Exemplo n.º 7
0
        private void RecreateObservable()
        {
            CancelBackgroundOperation();

            int fetchInterval;

            if (!int.TryParse(Settings.GetSetting(FetchIntervalSetting), out fetchInterval))
            {
                fetchInterval = 0;
            }

            bool autoRefresh;

            if (!bool.TryParse(Settings.GetSetting(AutoRefreshSetting), out autoRefresh))
            {
                autoRefresh = false;
            }

            var gitModule = currentGitUiCommands.GitModule;

            if (fetchInterval > 0 && GitModule.IsValidGitWorkingDir(gitModule.GitWorkingDir))
            {
                cancellationToken =
                    Observable.Timer(TimeSpan.FromSeconds(Math.Max(5, fetchInterval)))
                    .SkipWhile(i => gitModule.IsRunningGitProcess())
                    .Repeat()
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(i =>
                {
                    var gitCmd = Settings.GetSetting(GitCommandSetting).Trim();
                    var msg    = currentGitUiCommands.GitCommand(gitCmd);
                    if (autoRefresh)
                    {
                        if (gitCmd.StartsWith("fetch", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (msg.Contains("From"))
                            {
                                currentGitUiCommands.RepoChangedNotifier.Notify();
                            }
                        }
                        else
                        {
                            currentGitUiCommands.RepoChangedNotifier.Notify();
                        }
                    }
                }
                               );
            }
        }