Exemple #1
0
        private void Commit()
        {
            isBusy = true;
            var   files = treeChanges.GetCheckedFiles().ToList();
            ITask addTask;

            if (files.Count == gitStatusEntries.Count)
            {
                addTask = Repository.CommitAllFiles(commitMessage, commitBody);
            }
            else
            {
                addTask = Repository.CommitFiles(files, commitMessage, commitBody);
            }

            addTask
            .FinallyInUI((success, exception) =>
            {
                if (success)
                {
                    UsageTracker.IncrementChangesViewButtonCommit();

                    commitMessage = "";
                    commitBody    = "";
                }
                isBusy = false;
            }).Start();
        }
Exemple #2
0
        private void Commit()
        {
            isBusy = true;
            var   files   = treeChanges.GetCheckedFiles().ToList();
            ITask addTask = null;

            if (useCommitizen)
            {
                scope         = scope != "" ? string.Format("({0})", scope) : "";
                footer        = footer != "" ? string.Format("({0})", footer) : "";
                commitMessage = string.Format("{0}{1}:{2}{3}", commitType, scope, commitMessage, footer);
            }

            if (files.Count == gitStatusEntries.Count)
            {
                addTask = Repository.CommitAllFiles(commitMessage, commitBody);
            }
            else
            {
                ITask commit = Repository.CommitFiles(files, commitMessage, commitBody);

                // if there are files that have been staged outside of Unity, but they aren't selected for commit, remove them
                // from the index before commiting, otherwise the commit will take them along.
                var filesStagedButNotChecked = gitStatusEntries.Where(x => x.Staged).Select(x => x.Path).Except(files).ToList();
                if (filesStagedButNotChecked.Count > 0)
                {
                    addTask = GitClient.Remove(filesStagedButNotChecked);
                }
                addTask = addTask == null ? commit : addTask.Then(commit);
            }

            addTask
            .FinallyInUI((success, exception) =>
            {
                if (success)
                {
                    UsageTracker.IncrementChangesViewButtonCommit();

                    commitMessage = "";
                    commitBody    = "";
                }
                isBusy = false;
            }).Start();
        }