/// <summary>
        /// Exports the given changeset as a patch to a file.
        /// </summary>
        /// <param name="action"></param>
        public void ExportPatch(object action)
        {
            var commit = action as Commit;

            if (commit == null)
            {
                return;
            }

            var dialog = new SaveFileDialog
            {
                FileName   = commit.Description.Right(72),
                DefaultExt = ".patch",
                Filter     = "Patch files|*.patch"
            };

            if (dialog.ShowDialog() == false)
            {
                return;
            }

            var filename = dialog.FileName;

            Task.Run(() =>
            {
                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    File.WriteAllText(filename, RepoUtil.GetTreeChangesForCommit(repo, commit).Patch);
                }
            });
        }
Beispiel #2
0
        /// <summary>
        /// Copies the given changeset as a patch to clipboard.
        /// </summary>
        /// <param name="action"></param>
        public void CopyPatch(object action)
        {
            Commit commit = action as Commit;

            using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
            {
                Clipboard.SetText(RepoUtil.GetTreeChangesForCommit(repo, commit).Patch);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Exports the given changeset as a patch to a file.
        /// </summary>
        /// <param name="action"></param>
        public void ExportPatch(object action)
        {
            Commit commit = action as Commit;

            using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.FileName   = commit.Description.Right(72);
                dialog.DefaultExt = ".patch";
                dialog.Filter     = "Patch files|*.patch";

                if (dialog.ShowDialog() == true)
                {
                    // Save the patch to a file.
                    File.WriteAllText(dialog.FileName, RepoUtil.GetTreeChangesForCommit(repo, commit).Patch);
                }
            }
        }