mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34:59 +00:00
enhance: show file size change in image diff
This commit is contained in:
parent
54ef9c0bf7
commit
8b1f28ac95
3 changed files with 26 additions and 13 deletions
|
@ -157,14 +157,19 @@ namespace SourceGit.ViewModels
|
|||
var imgDiff = new Models.ImageDiff();
|
||||
if (_option.Revisions.Count == 2)
|
||||
{
|
||||
imgDiff.Old = BitmapFromRevisionFile(_repo, _option.Revisions[0], oldPath);
|
||||
imgDiff.New = BitmapFromRevisionFile(_repo, _option.Revisions[1], oldPath);
|
||||
(imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[0], oldPath);
|
||||
(imgDiff.New, imgDiff.NewFileSize) = BitmapFromRevisionFile(_repo, _option.Revisions[1], oldPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
var fullPath = Path.Combine(_repo, _option.Path);
|
||||
imgDiff.Old = BitmapFromRevisionFile(_repo, "HEAD", oldPath);
|
||||
imgDiff.New = File.Exists(fullPath) ? new Bitmap(fullPath) : null;
|
||||
(imgDiff.Old, imgDiff.OldFileSize) = BitmapFromRevisionFile(_repo, "HEAD", oldPath);
|
||||
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
imgDiff.New = new Bitmap(fullPath);
|
||||
imgDiff.NewFileSize = new FileInfo(fullPath).Length;
|
||||
}
|
||||
}
|
||||
rs = imgDiff;
|
||||
}
|
||||
|
@ -207,10 +212,11 @@ namespace SourceGit.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
private Bitmap BitmapFromRevisionFile(string repo, string revision, string file)
|
||||
private (Bitmap, long) BitmapFromRevisionFile(string repo, string revision, string file)
|
||||
{
|
||||
var stream = Commands.QueryFileContent.Run(repo, revision, file);
|
||||
return stream.Length > 0 ? new Bitmap(stream) : null;
|
||||
var size = stream.Length;
|
||||
return size > 0 ? (new Bitmap(stream), size) : (null, size);
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> IMG_EXTS = new HashSet<string>()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue