/// <summary>
        /// Reloads the git information provided on UI
        /// Output of git status --porcelain=v2 --branch --untracked=all (parsed) and git branch --list -r -a -v (raw) is provided to user
        /// </summary>
        private void RefreshGitInfo()
        {
            var result = ProcessUtils.RunCommand(
                "git", "status --porcelain=v2 --branch --untracked=all",
                SolutionInfo?.SolutionDir ?? Environment.CurrentDirectory,
                out var output);

            if (result)
            {
                var gitInfo = GitPorcelainParser.ParseGitPorcelain(output);
                InfoGitOverview.Text = $"Git: {gitInfo.Branch} {gitInfo.CommitShort} {gitInfo.CountsString} {gitInfo.Upstream}{(string.IsNullOrEmpty(gitInfo.Upstream) ? "" : " " + gitInfo.AB)}";
                InfoGitFiles.Text    = string.Join(Environment.NewLine, gitInfo.Files);
            }
            else
            {
                InfoGitOverview.Text = "Can't get git info!";
                InfoGitFiles.Text    = output;
            }

            result = ProcessUtils.RunCommand(
                "git", "branch --list -r -a -v",
                SolutionInfo?.SolutionDir ?? Environment.CurrentDirectory,
                out output);
            InfoGitBranches.Text = result ? output : $"Can't get branches info!{Environment.NewLine}{output}";
        }
Example #2
0
        public void Test1()
        {
            string        line          = " M WimyGit.sln";
            GitFileStatus gitFileStatus = GitPorcelainParser.ParseFileStatus(line);

            Assert.Equal("WimyGit.sln", gitFileStatus.Modified.Filename);
        }
        public void RefreshPending(List <string> porcelains)
        {
            if (_gitRepository.TryGetTarget(out IGitRepository gitRepository) == false)
            {
                return;
            }
            var modified_backup     = new SelectionRecover(ModifiedList);
            var staged_backup       = new SelectionRecover(StagedList);
            var collecting_staged   = new ObservableCollection <FileStatus>();
            var collecting_modified = new ObservableCollection <FileStatus>();

            foreach (var porcelain in porcelains)
            {
                GitFileStatus status = GitPorcelainParser.ParseFileStatus(porcelain);
                if (status.Staged != null)
                {
                    AddStagedList(status.Staged, staged_backup, collecting_staged);
                }
                if (status.Unmerged != null)
                {
                    AddModifiedList(status.Unmerged, modified_backup, collecting_modified);
                }
                if (status.Modified != null)
                {
                    AddModifiedList(status.Modified, modified_backup, collecting_modified);
                }
            }
            StagedList   = collecting_staged;
            ModifiedList = collecting_modified;

            NotifyPropertyChanged("StagedList");
            NotifyPropertyChanged("ModifiedList");

            if (ModifiedList.Count == 0 && StagedList.Count == 0)
            {
                gitRepository.AddLog("Nothing changed");
            }
        }