Esempio n. 1
0
        private async Task CommitAsync()
        {
            if (Stage.Count == 0 || string.IsNullOrWhiteSpace(Message))
            {
                return;
            }
            BarVisibility = Visibility.Visible;
            var commit = await _gitManager.GitCommitAsync(_message, _repositoryId, _stage);

            if (commit.Item1 == null)
            {
                MessageBox.Show(commit.Item2);
                BarVisibility = Visibility.Hidden;
                return;
            }
            if (IsPush)
            {
                await _gitManager.GitPushAsync(_repositoryId);
            }
            else
            {
                ColorPush = Brushes.Red;
            }
            Application.Current.Dispatcher.Invoke((System.Action) delegate
            {
                Commits.Insert(0, commit.Item1);
            });
            Stage.Clear();
            Message       = null;
            BarVisibility = Visibility.Hidden;
        }
Esempio n. 2
0
 public void VoltarCommits(Commits a)
 {
     Console.WriteLine("Regredindo versão...");
     this._nomeArquivo  = a.NomeArquivo;
     this._diretorio    = a.Diretorio;
     this._textoArquivo = a.Texto;
 }
Esempio n. 3
0
        private void InternalDispose()
        {
            PersistenceHelper.RemoveFromStack(this);

            var session = CurrentSessionContext.Unbind(PersistenceHelper.SessionFactory);

            if (Transaction != null)
            {
                if (!Commits.Contains(false))
                {
                    session.Transaction.Commit();
                }
                else
                {
                    Transaction.Rollback();
                }

                Transaction.Dispose();
            }

            if (session != null)
            {
                session.Close();
                session.Dispose();
            }
            if (TransactionScope != null)
            {
                TransactionScope.Complete();
            }
        }
        protected override Task Load(bool forceCacheInvalidation)
        {
            var t1 = this.RequestModel(() => this.GetApplication().Client.Users[Username].Repositories[Repository].PullRequests[PullRequestId].Get(forceCacheInvalidation), x => _pullRequest = x);
            var t2 = Commits.SimpleCollectionLoad(() => this.GetApplication().Client.Users[Username].Repositories[Repository].PullRequests[PullRequestId].GetCommits(forceCacheInvalidation));

            return(Task.WhenAll(t1, t2));
        }
Esempio n. 5
0
 void CleareContent()
 {
     Commits.Clear();
     Branches.Clear();
     Edges.Clear();
     View.Children.Clear();
 }
Esempio n. 6
0
            public IDictionary <string, object> GetHeaders()
            {
                var result = new Dictionary <string, object>();
                var commit = Commits.LastOrDefault();
                var source = default(IReadOnlyDictionary <string, object>);

                if (commit != null)
                {
                    source = commit.Headers;
                }
                else if (Snapshot != null)
                {
                    source = Snapshot.Headers;
                }

                if (source != null)
                {
                    foreach (var entry in source)
                    {
                        result.Add(entry.Key, entry.Value);
                    }
                }

                return(result);
            }
        private void ComboBoxUser_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SelectedFilters.SelectedTask = "";

            Commits.Clear();
            UserTasks.Clear();

            List <string> listTask = new List <string>();

            if (SelectedFilters.SelectedUser != null)
            {
                if (_dictionaryUserTasks.ContainsKey(SelectedFilters.SelectedUser))
                {
                    foreach (Models.Commit item in _dictionaryUserTasks[SelectedFilters.SelectedUser])
                    {
                        if (listTask.FirstOrDefault(f => f == item.Task) == null)
                        {
                            listTask.Add(item.Task);
                        }
                    }
                }
            }
            listTask.Sort();

            foreach (string item in listTask)
            {
                UserTasks.Add(item);
            }
        }
Esempio n. 8
0
        private IEnumerable <Commit> GetSimplifiedCommits()
        {
            foreach (var commit in Commits)
            {
                if (commit.ParentIds.Count() == 1 && commit.ChildIds.Count() == 1 && !this.Refs.Any(r => r.Id == commit.Id))
                {
                    var cid = commit.ChildIds[0];
                    var pid = commit.ParentIds[0];

                    var parent = Commits.Where(c => c.Id == pid).FirstOrDefault();
                    var child  = Commits.Where(c => c.Id == cid).FirstOrDefault();

                    if (parent != null && child != null)
                    {
                        int x1 = GetLane(parent.Id);
                        int x2 = GetLane(commit.Id);
                        int x3 = GetLane(child.Id);

                        if (x1 == x2 && x2 == x3)
                        {
                            commit.deleted = true;
                            parent.ChildIds[parent.ChildIds.IndexOf(commit.Id)] = cid;
                            child.ParentIds[child.ParentIds.IndexOf(commit.Id)] = pid;
                        }
                        //commit.ChildIds.Clear();
                        //commit.ParentIds.Clear();
                    }
                }
            }

            return(commits.Where(c => !c.deleted));
        }
        public CommitsEndpoint(Commits commits)
            : base("/commits")
        {
            Get["/{commitId}/testOutput.html"] = _ =>
            {
                var commit = commits.Get((string) _.commitId);
                if (commit == null)
                {
                    return new NotFoundResponse();
                }
                if (string.IsNullOrEmpty(commit.TestOutput))
                {
                    return null;
                }
                return Response.AsText(commit.TestOutput, commit.TestOutputFormat.ToMimeType());
            };

            Get["/{commitId}/buildOutput.txt"] = _ =>
            {
                var commit = commits.Get((string)_.commitId);
                if (commit == null)
                {
                    return new NotFoundResponse();
                }
                return Response.AsText(commit.BuildLog, "text/plain");
            };
        }
Esempio n. 10
0
        public bool Check()
        {
            if (!Directory.Exists(RepoDir))
            {
                Console.WriteLine("输入的文件夹不存在");
                return(false);
            }

            if (!Commits.Any())
            {
                Console.WriteLine("未指定任何提交标识");
                return(false);
            }

            if (string.IsNullOrEmpty(OutputDir))
            {
                OutputDir = Path.Combine(Environment.CurrentDirectory, DateTime.Now.ToString("yyyy-MM-dd HH fff"));
            }
            if (Directory.Exists(OutputDir))
            {
                Console.WriteLine($"指定的输出目录已存在,可能导致文件覆盖 {OutputDir}");
            }
            else
            {
                Directory.CreateDirectory(OutputDir);
            }

            return(true);
        }
Esempio n. 11
0
 /// <summary>
 /// Votes the roll back.
 /// </summary>
 public void VoteRollBack()
 {
     if (Transaction != null)
     {
         Commits.Add(false);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Votes the commit.
 /// </summary>
 public void VoteCommit()
 {
     if (Transaction != null)
     {
         Commits.Add(true);
     }
 }
Esempio n. 13
0
 public HashSet <T> CherryPick(string id)
 {
     if (!Commits.ContainsKey(id))
     {
         throw new KeyNotFoundException();
     }
     return(Commits[id].HashSet);
 }
Esempio n. 14
0
 private void UpdateCommitsRange(PullRequest pr)
 {
     Commits.Clear();
     Commits.Add(new CommitVm(pr.Base.Label, pr.Base.Sha));
     Commits.Add(new CommitVm(pr.Head.Label, pr.Head.Sha));
     BaseCommit = pr.Base.Sha;
     HeadCommit = pr.Head.Sha;
 }
 private void ClearProperties()
 {
     Commits.Clear();
     Users.Clear();
     UserTasks.Clear();
     SelectedFilters.ClearFilter();
     _dictionaryUserTasks.Clear();
 }
Esempio n. 16
0
 GitCommitInfo EnsureCommit(GitId id)
 {
     if (!Commits.TryGetValue(id, out var v))
     {
         Commits.Add(id, v = new GitCommitInfo(id, Repository));
     }
     return(v);
 }
Esempio n. 17
0
 public void Clear()
 {
     Commits?.Clear();
     Branches?.Clear();
     Edges?.Clear();
     CommitToModel?.Clear();
     ContentCleared?.Invoke();
 }
Esempio n. 18
0
        /// <summary>
        /// Stores the last RecentCommitMessageCount commit messages.
        /// </summary>
        private void LoadRecentCommitMessages()
        {
            RecentCommitMessages.Clear();

            foreach (Commit commit in Commits.Take(RecentCommitMessageCount))
            {
                RecentCommitMessages.Add(new RecentCommitMessage(commit.ShortDescription));
            }
        }
Esempio n. 19
0
                public override int GetHashCode()
                {
                    int hashCode = -87658868;

                    hashCode = hashCode * -1521134295 + Commits.GetHashCode();
                    hashCode = hashCode * -1521134295 + Labels.GetHashCode();
                    hashCode = hashCode * -1521134295 + Details.GetHashCode();
                    return(hashCode);
                }
Esempio n. 20
0
        public Log Log(string id)
        {
            if (!Commits.ContainsKey(id))
            {
                throw new KeyNotFoundException();
            }
            var commit = Commits[id];

            return(new Log(id, commit.Message));
        }
Esempio n. 21
0
        private void UpdateViewModelImpl()
        {
            Commits.ForEach(commit => commit.WindowWidth = Width);
            CommitDetailsViewModel.NotifyAll();
            NotifyAll();

            VirtualItemsSource.DataChanged(width);

            UpdateStatusIndicators();
        }
Esempio n. 22
0
 public void Validate()
 {
     if (Repository == null)
     {
         throw new ArgumentException("Repository must not be null");
     }
     if (Commits.Count() < 2)
     {
         throw new ArgumentException("Need at least two commits to merge");
     }
 }
Esempio n. 23
0
        public bool AddCommit(ICommit commit)
        {
            if (commit is GitCommit gitCommit)
            {
                Commits.AddFirst(gitCommit);
                return(true);
            }

            Console.WriteLine("Only Git commits can be added to a git branch!");
            return(false);
        }
Esempio n. 24
0
        public MCommit Commit(CommitId commitId)
        {
            MCommit commit;

            if (!Commits.TryGetValue(commitId, out commit))
            {
                commit = AddNewCommit(commitId);
            }

            return(commit);
        }
Esempio n. 25
0
 public TimeSpan FirstCommitToMergeTime()
 {
     if (!MergedAt.HasValue)
     {
         return(DateTime.Now.Subtract(Commits.First().Details.Committer.CommitDate));
     }
     else
     {
         return(MergedAt.Value.Subtract(Commits.First().Details.Committer.CommitDate));
     }
 }
Esempio n. 26
0
 public void Checkout(string id)
 {
     if (!Commits.ContainsKey(id))
     {
         throw new KeyNotFoundException();
     }
     Clear();
     foreach (var commit in Commits[id].HashSet)
     {
         Add(commit);
     }
 }
Esempio n. 27
0
 public void VoltarCommits(Commits a)
 {
     Console.WriteLine("Regredindo versão...");
     this._nomeArquivo  = a.NomeArquivo;
     this._diretorio    = a.Diretorio;
     this._textoArquivo = a.Texto;
     File.Delete(_diretorio);
     using (StreamWriter sw = File.CreateText(_diretorio))
     {
         sw.WriteLine(_textoArquivo + " pegou");
     }
 }
Esempio n. 28
0
 private void StoreNewCommits(IEnumerable <Commit> loadedCommits)
 {
     //This has quadratic runtime, O(commits.Count * newlist.Count),
     //but thats ok as long as newlist.Count is limited to 10
     foreach (var commit in loadedCommits)
     {
         if (!Enumerable.Contains(Commits, commit))
         {
             Commits.Add(commit);
         }
     }
 }
        private void CalendarViewDateTaskChanged_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
        {
            List <DateTimeOffset> listRemovedDates = args.RemovedDates.ToList();

            for (int i = Commits.Count - 1; i >= 0; --i)
            {
                if (listRemovedDates.FirstOrDefault(f => f.Date.StartDay() == Commits[i].Date.StartDay()) != default(DateTimeOffset))
                {
                    Commits.RemoveAt(i);
                }
            }
        }
        void RefreshSelectedBranch()
        {
            BranchViewModel = RepositoriesViewModel.SelectedBranch;
            if (BranchViewModel?.MergeRequest == null)
            {
                Commits = Enumerable.Empty <CommitViewModel>();
                return;
            }
            var mergeRequest = BranchViewModel.MergeRequest;

            Commits = mergeRequest.Commits;
            Commits.ForEach(x => x.UpdateBuilds());
        }
Esempio n. 31
0
 public void Reset(string id)
 {
     Checkout(id);
     foreach (var history in Histories.ToList())
     {
         Commits.Remove(history);
         Histories.Remove(history);
         if (history.Equals(id))
         {
             break;
         }
     }
 }
        public UsersEndpoint(Users users, Commits commits, AppSettings settings, DcsScm scm)
            : base("/users")
        {
            Get["/"] = _ =>
            {
                string token = Request.Query.token;
                if (token.ToNullableGuid() != FakeyAuth.Token)
                {
                    return new Response
                    {
                        StatusCode = HttpStatusCode.Forbidden
                    };
                }

                return users.GetAll()
                    .Select(u =>
                    {
                        var user = new
                        {
                            Username = u.Username,
                            u.Id
                        };

                        return user;
                    }
                    );
            };

            Get["/{userId}"] = _ =>
            {
                var user = users.Get((Guid) _.userId);
                if (user == null)
                {
                    return new NotFoundResponse();
                }
                var repo = user.Repositories.FirstOrDefault();
                return new
                {
                    Username = user.Username,
                    user.Id,
                    user.Email,
                    RepositoryHref = repo == null ? null : scm.GetRepoUrl(repo.Name, user, true),
                    Challenges = user.Challenges.Select(c =>
                    new {
                        c.Name,
                        c.StageNumber,
                        c.RepositoryId
                    })
                };
            };

            Get["/{userId}/commits"] = _ =>
                commits.ForUser((Guid) _.userId)
                    .OrderByDescending(c => c.CommittedAt)
                    .Select(c =>
                        new
                        {
                            c.Id,
                            c.CommittedAt,
                            c.UserId,
                            c.Username,
                            c.RepositoryId,
                            c.RepositoryName,
                            c.Challenge,
                            c.CurrentStageNumber,
                            c.ResultsUpdatedAt,
                            c.Outcome,
                            c.OutcomeDetail,
                            HasTestOutput = !string.IsNullOrEmpty(c.TestOutput)
                        });
        }