/// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            GitCommandExecuter gitExecuter = new GitCommandExecuter(_gitService);
            GitCommandResult   result      = gitExecuter.Execute(ExtensionConstants.PullOriginDevelopment);

            BringPanelToFront();

            WriteLineToOutputWindow("########################################");
            if (result.IsError)
            {
                WriteLineToOutputWindow($"Git Error - at {DateTime.Now}");
                WriteLineToOutputWindow(result.ErrorMessage);
            }
            else
            {
                WriteLineToOutputWindow($"Git Command OK - at {DateTime.Now}");
            }
            WriteLineToOutputWindow("########################################");
            WriteLineToOutputWindow(String.Empty);

            WriteLineToOutputWindow(result.OutputMessage);
            WriteLineToOutputWindow(String.Empty);
            WriteLineToOutputWindow(String.Empty);
        }
示例#2
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            CommandsWindow window = new CommandsWindow();

            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.ShowDialog();

            if (window.SelectedGitCommand != null)
            {
                var gitCommand = window.SelectedGitCommand;
                GitCommandExecuter gitExecuter = new GitCommandExecuter(_gitService);
                GitCommandResult   result      = gitExecuter.Execute(gitCommand);

                BringPanelToFront();

                WriteLineToOutputWindow("########################################");
                if (result.IsError)
                {
                    WriteLineToOutputWindow($"Git Error - at {DateTime.Now}");
                    WriteLineToOutputWindow(result.ErrorMessage);
                }
                else
                {
                    WriteLineToOutputWindow($"Git Command OK - at {DateTime.Now}");
                }
                WriteLineToOutputWindow("########################################");
                WriteLineToOutputWindow(String.Empty);

                WriteLineToOutputWindow(result.OutputMessage);
                WriteLineToOutputWindow(String.Empty);
                WriteLineToOutputWindow(String.Empty);
            }
        }
 public CreateStashSetionViewModel(IServiceProvider serviceProvider)
 {
     _serviceProvider    = serviceProvider;
     _teamExplorer       = _serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
     _gitCommandExecuter = new GitCommandExecuter(serviceProvider);
     _dte = _serviceProvider.GetService(typeof(DTE)) as DTE;
 }
        public StashInfoChangesSectionViewModel(Stash stash, FileIconsService fileIconsService, GitCommandExecuter gitCommandExecuter, ITeamExplorer teamExplorer, IVsDifferenceService vsDiffService)
        {
            _fileIconsService   = fileIconsService;
            _gitCommandExecuter = gitCommandExecuter;
            _teamExplorer       = teamExplorer;
            _vsDiffService      = vsDiffService;
            _stash = stash;

            if (stash == null)
            {
                return;
            }

            var separator = '/';
            var rootNode  = new TreeNode();
            var paths     = stash.ChangedFiles
                            .Select(f => f.Path)
                            .Where(x => !string.IsNullOrEmpty(x.Trim()))
                            .ToList();

            foreach (var path in paths)
            {
                var currentNode = rootNode;
                var pathNodes   = path.Split(separator);
                foreach (var item in pathNodes)
                {
                    var foundedNode = currentNode.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == item);
                    currentNode = foundedNode ?? currentNode.Nodes.Add(item);
                }
            }

            var rootTreeViewItem = ToTreeViewItem(rootNode, false);

            ChangeItems = new ObservableCollection <TreeViewItemWithIcon>(rootTreeViewItem.Items.ToList());
        }
示例#5
0
        public StashInfoChangesSectionViewModel(Stash stash,
                                                FileIconsService fileIconsService,
                                                GitCommandExecuter gitCommandExecuter,
                                                ITeamExplorer teamExplorer,
                                                IVsDifferenceService vsDiffService,
                                                DTE dte)
        {
            _fileIconsService   = fileIconsService;
            _gitCommandExecuter = gitCommandExecuter;
            _teamExplorer       = teamExplorer;
            _vsDiffService      = vsDiffService;
            _dte   = dte;
            _stash = stash;

            if (stash == null)
            {
                return;
            }

            var separator = '/';
            var rootNode  = new TreeNode();

            foreach (var file in stash.ChangedFiles)
            {
                if (string.IsNullOrEmpty(file.Path.Trim()))
                {
                    continue;
                }

                var currentNode = rootNode;
                var pathNodes   = file.Path.Split(separator);
                foreach (var item in pathNodes)
                {
                    var foundedNode = currentNode.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == item);
                    if (foundedNode != null)
                    {
                        currentNode = foundedNode;
                    }
                    else
                    {
                        currentNode = currentNode.Nodes.Add(item);
                        // Last node in the path -> file.
                        if (item == pathNodes.LastOrDefault())
                        {
                            // Additional file info
                            currentNode.Tag = new Models.FileAttributes
                            {
                                IsNew    = file.IsNew,
                                IsStaged = file.IsStaged
                            };
                        }
                    }
                }
            }

            var rootTreeViewItem = ToTreeViewItem(rootNode, false);

            ChangeItems = new ObservableCollection <TreeViewItemWithIcon>(rootTreeViewItem.Items?.ToList() ?? Enumerable.Empty <TreeViewItemWithIcon>());
        }
 public VisualStudioGitService(IServiceProvider serviceProvider)
 {
     _dialogFactory      = serviceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)) as IVsThreadedWaitDialogFactory;
     _gitCommandExecuter = new GitCommandExecuter(serviceProvider);
     _teamExplorer       = serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
     _dte           = serviceProvider.GetService(typeof(DTE)) as DTE;
     _vsDiffService = serviceProvider.GetService(typeof(SVsDifferenceService)) as IVsDifferenceService;
 }
        public StashInfoChangesSectionUI(Stash stash, IServiceProvider serviceProvider)
        {
            _serviceProvider    = serviceProvider;
            _vsImageService     = _serviceProvider.GetService(typeof(SVsImageService)) as IVsImageService2;
            _fileIconsService   = new FileIconsService(_vsImageService);
            _gitCommandExecuter = new GitCommandExecuter(_serviceProvider);
            _teamExplorer       = _serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
            _vsDiffService      = _serviceProvider.GetService(typeof(SVsDifferenceService)) as IVsDifferenceService;
            InitializeComponent();

            DataContext = _viewModel = new StashInfoChangesSectionViewModel(stash, _fileIconsService, _gitCommandExecuter, _teamExplorer, _vsDiffService);
        }
示例#8
0
        public StashListSectionViewModel(IServiceProvider serviceProvider)
        {
            _serviceProvider    = serviceProvider;
            _teamExplorer       = _serviceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
            _gitCommandExecuter = new GitCommandExecuter(serviceProvider);
            _gitService         = new VisualStudioGitService(_serviceProvider);

            UpdateStashList(string.Empty);
            RemovedStashesContainer.ResetContainer();

            PropertyChanged += (e, s) =>
            {
                if (s.PropertyName == nameof(SearchText))
                {
                    UpdateStashList(SearchText);
                }
            };
        }