示例#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;
        }
示例#2
0
        /// <summary>
        ///     Appends a new commit in the history.
        ///     IF the commit is already present, it replaces that commit instead
        /// </summary>
        /// <param name="commit"></param>
        public void AppendOrReplaceCommit(Commit commit)
        {
            int found = -1;
            int index = 0;

            while (index < Commits.Count && found < 0)
            {
                Commit other = (Commit)Commits[index];
                if (other.Sha == commit.Sha)
                {
                    found = index;
                }
                index += 1;
            }

            Commits.Insert(index, commit);
            commit.setFather(this);
            if (found >= 0)
            {
                Commits.RemoveAt(found);
            }
        }