Exemple #1
0
        internal BranchTrackingDetails(Repository repo, Branch branch)
        {
            if (!branch.IsTracking || branch.Tip == null || branch.TrackedBranch.Tip == null)
            {
                historyDivergence = new NullHistoryDivergence();
                return;
            }

            historyDivergence = repo.ObjectDatabase.CalculateHistoryDivergence(branch.Tip, branch.TrackedBranch.Tip);
        }
        internal BranchTrackingDetails(Repository repo, Branch branch)
        {
            if (!branch.IsTracking || branch.Tip == null || branch.TrackedBranch.Tip == null)
            {
                historyDivergence = new NullHistoryDivergence();
                return;
            }

            historyDivergence = repo.ObjectDatabase.CalculateHistoryDivergence(branch.Tip, branch.TrackedBranch.Tip);
        }
Exemple #3
0
        public void CanCalculateHistoryDivergenceWhenNoAncestorIsShared(
            string sinceSha, string untilSha,
            int?expectedAheadBy, int?expectedBehindBy)
        {
            using (var repo = new Repository(BareTestRepoPath))
            {
                var since = repo.Lookup <Commit>(sinceSha);
                var until = repo.Lookup <Commit>(untilSha);

                HistoryDivergence div = repo.ObjectDatabase.CalculateHistoryDivergence(since, until);

                Assert.Equal(expectedAheadBy, div.AheadBy);
                Assert.Equal(expectedBehindBy, div.BehindBy);
                Assert.Null(div.CommonAncestor);
            }
        }
Exemple #4
0
        public void CanCalculateHistoryDivergence(
            string sinceSha, string untilSha,
            string expectedAncestorSha, int?expectedAheadBy, int?expectedBehindBy)
        {
            string path = SandboxBareTestRepo();

            using (var repo = new Repository(path))
            {
                var since = repo.Lookup <Commit>(sinceSha);
                var until = repo.Lookup <Commit>(untilSha);

                HistoryDivergence div = repo.ObjectDatabase.CalculateHistoryDivergence(since, until);

                Assert.Equal(expectedAheadBy, div.AheadBy);
                Assert.Equal(expectedBehindBy, div.BehindBy);
                Assert.Equal(expectedAncestorSha, div.CommonAncestor.Id.ToString(7));
            }
        }
Exemple #5
0
        public void UpdateGitNotification(
            HistoryDivergence divergenceWithDevelop,
            HistoryDivergence divergenceWithRemote)
        {
            if (divergenceWithDevelop.BehindBy > 0)
            {
                Console.WriteLine($"{DateTime.Now} Behind origin/develop by: {divergenceWithDevelop.BehindBy}");
            }
            else
            {
            }

            if (divergenceWithRemote.AheadBy > 0)
            {
                Console.WriteLine($"{DateTime.Now} Unpushed commits: {divergenceWithRemote.AheadBy}");
            }
            else
            {
            }
        }
        public void UpdateGitNotification(
            HistoryDivergence divergenceWithDevelop,
            HistoryDivergence divergenceWithRemote)
        {
            if (divergenceWithDevelop.BehindBy > 0)
            {
                Debug.WriteLine("Behind origin/develop by: {0}", divergenceWithDevelop.BehindBy);
                Chroma.Instance.Keyboard.SetKeys(new Color(0.0, 0.0, 1.0), Key.Macro2);
            }
            else
            {
                Chroma.Instance.Keyboard.SetKeys(new Color(120, 200, 240), Key.Macro2);
            }

            if (divergenceWithRemote.AheadBy > 0)
            {
                Debug.WriteLine("unpushed commits: {0}", divergenceWithRemote.AheadBy);
                Chroma.Instance.Keyboard.SetKeys(new Color(1.0, 0.0, 1.0), Key.Macro3);
            }
            else
            {
                Chroma.Instance.Keyboard.SetKeys(new Color(120, 200, 240), Key.Macro3);
            }
        }