Esempio n. 1
0
        public async Task <DraftEntryPoint> Begin([FromServices] ISyncRepository syncRepo)
        {
            var syncInfo = await syncRepo.SyncInfo();

            return(new DraftEntryPoint()
            {
                HasUncommittedChanges = syncInfo.HasUncomittedChanges,
                HasUnsyncedChanges = syncInfo.NeedsPull || syncInfo.NeedsPush
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Get the current status of the compiler.
        /// </summary>
        /// <returns></returns>
        public async Task <PublishEntryPoint> GetPublishInfo(ISyncRepository syncRepo)
        {
            var publishRepoPath = projectFinder.PublishedProjectPath;
            var masterRepoPath  = projectFinder.MasterRepoPath;

            var compilerStatus = new PublishEntryPoint()
            {
                BehindBy      = -1,
                BehindHistory = null
            };

            if (publishRepoPath != masterRepoPath)
            {
                using (var repo = new Repository(publishRepoPath))
                {
                    var startInfo = new ProcessStartInfo("git")
                    {
                        ArgumentList = { "fetch", "--all" }, WorkingDirectory = repo.Info.WorkingDirectory
                    };
                    processRunner.Run(startInfo);

                    var head       = repo.Head.Commits.First();
                    var tracked    = repo.Head.TrackedBranch.Commits.First();
                    var divergence = repo.ObjectDatabase.CalculateHistoryDivergence(head, tracked);

                    var behindCommits = repo.Commits.QueryBy(new CommitFilter()
                    {
                        SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Time,
                        IncludeReachableFrom = divergence.Another,
                        ExcludeReachableFrom = divergence.CommonAncestor
                    });

                    compilerStatus.BehindBy      = divergence.BehindBy.GetValueOrDefault();
                    compilerStatus.BehindHistory = behindCommits.Select(c => new History(c)).ToList();
                    var syncInfo = await syncRepo.SyncInfo();

                    compilerStatus.HasUncommittedChanges = syncInfo.HasUncomittedChanges;
                    compilerStatus.HasUnsyncedChanges    = syncInfo.NeedsPull || syncInfo.NeedsPush;
                }
            }

            return(compilerStatus);
        }