mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
refactor: rewrite Commands.QueryFileContent and use it instead of GetImageFileAsBitmap
This commit is contained in:
parent
9a4f928ece
commit
8dd1ce9185
4 changed files with 44 additions and 64 deletions
|
@ -101,13 +101,13 @@ namespace SourceGit.ViewModels
|
|||
var imgDiff = new Models.ImageDiff();
|
||||
if (option.Revisions.Count == 2)
|
||||
{
|
||||
imgDiff.Old = Commands.GetImageFileAsBitmap.Run(repo, option.Revisions[0], oldPath);
|
||||
imgDiff.New = Commands.GetImageFileAsBitmap.Run(repo, option.Revisions[1], oldPath);
|
||||
imgDiff.Old = BitmapFromRevisionFile(repo, option.Revisions[0], oldPath);
|
||||
imgDiff.New = BitmapFromRevisionFile(repo, option.Revisions[1], oldPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullPath = Path.Combine(repo, _option.Path);
|
||||
imgDiff.Old = Commands.GetImageFileAsBitmap.Run(repo, "HEAD", oldPath);
|
||||
imgDiff.Old = BitmapFromRevisionFile(repo, "HEAD", oldPath);
|
||||
imgDiff.New = File.Exists(fullPath) ? new Bitmap(fullPath) : null;
|
||||
}
|
||||
rs = imgDiff;
|
||||
|
@ -163,6 +163,12 @@ namespace SourceGit.ViewModels
|
|||
Task.Run(() => Commands.MergeTool.OpenForDiff(_repo, exec, args, _option));
|
||||
}
|
||||
|
||||
private Bitmap BitmapFromRevisionFile(string repo, string revision, string file)
|
||||
{
|
||||
var stream = Commands.QueryFileContent.Run(repo, revision, file);
|
||||
return stream != null ? new Bitmap(stream) : null;
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> IMG_EXTS = new HashSet<string>()
|
||||
{
|
||||
".ico", ".bmp", ".jpg", ".png", ".jpeg"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue