Esempio n. 1
0
        static bool IsCheckoutBlockingDirty(RepositoryStatus status)
        {
            if (status.IsDirty)
            {
                return(status.Any(entry => IsCheckoutBlockingChange(entry)));
            }

            return(false);
        }
Esempio n. 2
0
        static bool IsFilthy(RepositoryStatus status)
        {
            if (status.IsDirty)
            {
                // This is similar to IsDirty, but also allows NewInWorkdir files
                return(status.Any(entry =>
                                  entry.State != FileStatus.Ignored &&
                                  entry.State != FileStatus.Unaltered &&
                                  entry.State != FileStatus.NewInWorkdir));
            }

            return(false);
        }
Esempio n. 3
0
        protected override void OnGitUpdate(RepositoryStatus status)
        {
            //update all branches
            cachedBranches = GitManager.Repository.Branches.Select(b => new BranchInfo(b)).ToArray();

            //update selected branch
            UpdateSelectedBranch();

            if (selectedBranch != null)
            {
                //update commits and limit them depending on settings
                cachedCommits = (GitManager.Settings.MaxCommits >= 0 ? selectedBranch.LoadBranch().Commits.Take(GitManager.Settings.MaxCommits) : selectedBranch.LoadBranch().Commits).Take(GitManager.Settings.MaxCommits).Select(c => new CommitInfo(c, cachedBranches.Where(b => b.Tip.Id == c.Id).ToArray())).ToArray();

                commitRects = new Rect[cachedCommits.Length];
            }

            hasConflicts       = status.Any(s => s.State == FileStatus.Conflicted);
            titleContent.image = GitManager.GetGitStatusIcon();
            Repaint();
        }
Esempio n. 4
0
        protected override void HandleGit(Repository repo, string directory, string relativeDir, string repoUrl)
        {
            var options = new StatusOptions
            {
                IncludeIgnored         = IncludeIgnored,
                IncludeUntracked       = !ExcludeUntracked,
                Show                   = StatusShowOption.IndexAndWorkDir,
                DetectRenamesInIndex   = true,
                DetectRenamesInWorkDir = true,
            };
            RepositoryStatus status     = repo.RetrieveStatus(options);
            bool             hasChanges = status.Any();

            PrintLine($"{(hasChanges ? Cyan : White)}{relativeDir}");

            Branch currentBranch = repo.Branches.FirstOrDefault(b => b.IsCurrentRepositoryHead && !b.IsRemote);

            if (currentBranch is null)
            {
                return;
            }

            var branchStr = new ColorString("    ## ").Green(currentBranch.FriendlyName);

            if (currentBranch.IsTracking)
            {
                branchStr = branchStr
                            .Reset("...")
                            .Red(currentBranch.TrackedBranch.FriendlyName);

                if (currentBranch.TrackingDetails.AheadBy.HasValue)
                {
                    int aheadBy = currentBranch.TrackingDetails.AheadBy.Value;
                    if (aheadBy != 0)
                    {
                        branchStr = branchStr
                                    .Reset(" [ahead: ")
                                    .Green(aheadBy.ToString())
                                    .Reset("]");
                    }
                }
                if (currentBranch.TrackingDetails.BehindBy.HasValue)
                {
                    int behindBy = currentBranch.TrackingDetails.BehindBy.Value;
                    if (behindBy != 0)
                    {
                        branchStr = branchStr
                                    .Reset(" [behind: ")
                                    .Red(behindBy.ToString())
                                    .Reset("]");
                    }
                }
            }
            PrintLine(branchStr);

            if (!hasChanges)
            {
                return;
            }

            foreach (StatusEntry statusItem in status)
            {
                ColorString statusStr = Statuses
                                        .Where(s => (statusItem.State & s.status) == s.status)
                                        .Aggregate(new ColorString("    "), (acc, s) => acc.Text(s.display, s.color));
                statusStr = statusStr.Text($" {statusItem.FilePath}", CColor.Reset);
                PrintLine(statusStr);
                if ((statusItem.State & FileStatus.RenamedInIndex) == FileStatus.RenamedInIndex)
                {
                    RenameDetails details = statusItem.HeadToIndexRenameDetails;
                    PrintLine($"      {details.OldFilePath} => {details.NewFilePath} (Similarity: {details.Similarity})");
                }
                if ((statusItem.State & FileStatus.RenamedInWorkdir) == FileStatus.RenamedInWorkdir)
                {
                    RenameDetails details = statusItem.IndexToWorkDirRenameDetails;
                    PrintLine($"      {details.OldFilePath} => {details.NewFilePath} (Similarity: {details.Similarity})");
                }
            }
        }